There is no block scope, variables live in a function or a file.
In order to create a list of closure functions in a loop closing over different variables - like in the OP's first example - one would need to call an explicit generator function, having the var in its scope and returning the closure.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
In reply to Re^2: Closures and scope of lexicals
by LanX
in thread Closures and scope of lexicals
by haj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |