We don't bite newbies here... much | |
PerlMonks |
Re^2: Last undefines a for loop's itererator?by Animator (Hermit) |
on Nov 12, 2005 at 11:20 UTC ( [id://507965]=note: print w/replies, xml ) | Need Help?? |
Some additional comment on this: you really don't want $picture to be set outside the loop. It would make debbuging really hard. As [id://dave_the_m] said: it is an alias. Meaning if you do $picture = "something else"; then the original value will change. Limiting the effect of the alias to the foreach-block (and everything that is called via the foreach-block and still is in the lexical-scope of the variable) is a really good thing. (Because it reduces the code you need to look at when debugging.) Also note that it is not last that undefines it. For example: for my $x (0 .. 3) { } print $x;==> it won't print 3.
Update: added comment about last
In Section
Seekers of Perl Wisdom
|
|