in reply to $_ scoping issues
When you do foreach (list_of_stuff), $_ is aliased to each entry in the list in turn. Hence, $_ *is* $u->{loc} and has the same address.
If you want to copy each list element into another variable for processing (which is generally the wise thing to do) the usual solution would be foreach my $foo (list_of_stuff).
On an unrelated issue, I betcha that foreach ($u->{loc}) is a bug. $u->{loc} is, and always will be, a scalar, so there's no point in the foreach.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: $_ scoping issues
by swkronenfeld (Hermit) on Jul 18, 2003 at 22:19 UTC |
In Section
Seekers of Perl Wisdom