Oh, eval will let you do this:
push @closures, eval "sub { print "\Q$j\E" }";
(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. |