http://www.perlmonks.org?node_id=719489


in reply to Re^2: Lexical closures
in thread Lexical closures

Yes! Thanks. I've never think about aliasing longer than the easy way to work on the elements of an array directly, that is the purpose, in most case, of the foreach loop.

But, I'm continuing playing with that and realize aliasing also implies narrowing the scope of the variable to the loop,

my $i = 123; foreach $i (0..3) { ; } print "$i\n"; # 123

No? If it does not narrow it itself the final value of $i should be 3.

If so, the funny thing is in "foreach my $i" my is not revelant as far we do not control in fact the scope of $i at this point. So, can we consider a bug, or at least an over sanity warn, the fact strict.pm forces us to put it here?