http://qs321.pair.com?node_id=64950


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.
while (<FH>) { # localized $_ for (split ' ') { # localized $_ } # previous $_ }
It's when you start doing silly and dangerous things like:
sub foo { $_ = shift; # TSK! local $_ tr/aeiou/AEIOU/; return $_; }
that problems occur. It is a bad idea to assign to a global $_ -- where "global" means "not localized".

japhy -- Perl and Regex Hacker