use strict;
use warnings;
my $i = "Nothing to see here, move along\n";
for $i (1 .. 3) {
print "$i ";
}
print $i;
Prints:
1 2 3 Nothing to see here, move along
The for loop variable is aliased to the elements in the for list. Any global (to the loop) variable that happens to have the same name is unaffected by the loop and, in particular, does not end up with the last contents of the loop variable!
True laziness is hard work
|