Your good reason has a corollary, which happens to be another good reason to use the original code. This modifies the original array:
@array = 1 .. 10; for my $var (@array) { $var++; print "$var\n"; } print "@array\n";
But this does not:
@array = 1 .. 10; for (@array) { my $var = $_; $var++; print "$var\n"; } print "@array\n";
In reply to Re^3: Pearls (not really) of Perl programming
by revdiablo
in thread Pearls (not really) of Perl programming
by PetaMem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |