in reply to Re: Simple question about foreach and my.
in thread Simple question about foreach and my.

I believe that 5.004 introduced it.

In older Perl's I write like this:

foreach (@array) { my $var = $_; # ... }
which keeps the loop variable private. (At the cost of opening yourself up to wiping out your array if you call something that walks over $_ unexpectedly.)