Yes. $_ is a package variable. $index is a lexical. In the first case, you have a closure which closes over $index; in the second, you simply have an anonymous function that prints a global variable.
I do find it curious that you get 11 different $index variables, though; I would expect you’d get only one. I’m not entirely sure of how foreach works in this respect.
Makeshifts last the longest.
In reply to Re: Are we seeing syntax inconsistency?
by Aristotle
in thread Are we seeing syntax inconsistency?
by TibetPerlMonk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |