can someone explain this behaviour to me:
I had expected that within the loop the previously declared variable would be used and with each iteration it would be assigned a new value, so that after the loop it should have the new value 7.use strict; my $i = "whatever"; for $i (1..10) { last if $i == 7; } print "$i\n"; # prints "whatever"
But that's not how it works.
The loop does not seem to change the value of $i at all - but why?
Many thanks!
In reply to loop surprise by morgon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |