(Note that if you don't quotemeta the variable, you open yourself up to all sorts of headaches - and a security hole if $j contains user input dependent data.)
But why would you want that? Just create a unique copy of the lexicals in question during each loop iteration and you'll be fine. There's no reason to resort to eval STRING for this job. As all others have already proposed:
my $my_j = $j; push @closures, sub { print $my_j };
Makeshifts last the longest.
In reply to Re^4: Closure Confusion
by Aristotle
in thread Closure Confusion
by Dinosaur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |