In older Perl's I write like this:
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.)foreach (@array) { my $var = $_; # ... }
In reply to Re (tilly) 2: Simple question about foreach and my.
by tilly
in thread Simple question about foreach and my.
by Xxaxx
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |