|
|
| Perl: the Markov chain saw | |
| PerlMonks |
Re^2: why need my in a foreach loop?by 7stud (Deacon) |
| on Nov 28, 2010 at 19:59 UTC ( #874133=note: print w/ replies, xml ) | Need Help?? |
|
Here's the difference:
In ikegami's example, the my is omitted in the for loop, which causes the for loop to change the global variable $foo--and the subroutine prints the global $foo (i.e. the subroutine is a closure).
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||