in reply to Re: What would you do?
in thread What would you do?
Not quite. The first method does not assign to the same $_ that the while loop uses. If it did, you couldn't use $_ in that for loop at all.
japhy -- Perl and Regex Hacker
It's when you start doing silly and dangerous things like:while (<FH>) { # localized $_ for (split ' ') { # localized $_ } # previous $_ }
that problems occur. It is a bad idea to assign to a global $_ -- where "global" means "not localized".sub foo { $_ = shift; # TSK! local $_ tr/aeiou/AEIOU/; return $_; }
japhy -- Perl and Regex Hacker
|
---|
Replies are listed 'Best First'. | |
---|---|
Does while localize $_?
by tenya (Beadle) on Mar 18, 2001 at 22:40 UTC | |
by danger (Priest) on Mar 19, 2001 at 00:07 UTC | |
by merlyn (Sage) on Mar 19, 2001 at 00:07 UTC | |
by tenya (Beadle) on May 25, 2001 at 07:46 UTC |
In Section
Seekers of Perl Wisdom