On Sun, 04 Mar 2012 11:15:34 +0000 Rob Dixon <rob.di...@gmx.com> wrote:
... > > $_ is a package variable. You can fully-qualify it here and access it > as $main::_. > > Perl itself takes care of using $_ in foreach loops by localizing it > within every such loop. The problem is usually when it is implicitly > used in a while loop, as here. If you use a named variable in read > loops then you should be safe. > That is interesting. I tried it and having the subs in the same file did a 'my $_' in the sub, and then it worked. However, from a coding style point of view it is surely a good idea to use 'my $somevar' in the foreach loop in most of the cases. -- Thanks much, Manfred -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/