in reply to Re: references--hard vs anonymous operational weirdness
in thread references--hard vs anonymous operational weirdness
Only if @array was declared outside the loop.</nit>
my @array; for my $tab ( @things ) { @array = frobnicate( $tab ); ## As you've seen, this leaves everything pointing at the same array $data{ $tab } = \@array; }
Were @array declared inside the loop you'd get a fresh instance each time through.
for my $tab ( @things ) { my @array = frobnicate( $tab ); $data{ $tab } = \@array; }
The cake is a lie.
The cake is a lie.
The cake is a lie.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: references--hard vs anonymous operational weirdness
by hipowls (Curate) on Mar 23, 2008 at 03:43 UTC | |
by chromatic (Archbishop) on Mar 23, 2008 at 03:55 UTC | |
by hipowls (Curate) on Mar 23, 2008 at 04:19 UTC | |
by ikegami (Patriarch) on Mar 23, 2008 at 04:41 UTC | |
by chromatic (Archbishop) on Mar 23, 2008 at 05:44 UTC | |
| |
by hipowls (Curate) on Mar 24, 2008 at 10:02 UTC | |
|
In Section
Seekers of Perl Wisdom