Perl Monk, Perl Meditation | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
There is a difference between localizing $_ and aliasing it to something else. Do not confuse the two. Note also that there is no construct which implicitly localizes $_, but there are several which alias it to something else. Obviously, while(<FH>) cannot alias the variable to anything, because one would have to be able to expect that modifying $_ would actually modify the file. Instead, readline returns a copy of the data found in the file. It really is obvious and very consistent if you think about it. Perl just DWIMs well enough in so many cases that it's easy to overlook some of the ramifications of any single operation. Makeshifts last the longest. In reply to Re^4: Playing with non-localized $_ in nested loops.
by Aristotle
|
|