in reply to Access a global variable from a subroutine when used as "for" iterator

The implicit local-ization of foreach-loop vars comes with some magic side effects.°

If you really want that closure ( NB: it's NOT a "global variable" ) better use other loops like c-style for (;;) or while() or just do like you said and copy the loop-var to the closure var.

Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery

°) IMHO stemming in compatibility to Perl4 which didn't have my