in each iteration a new variable $i is created. the old $i (from the former loop iteration) is no longer accessible via $i, but because there is a subroutine referencing it, it is not garbage collected.foreach my $i (0 .. 2) { push @d, sub { print "$i\n" }; }
In reply to Re: evaluation strategy of perl
by kabel
in thread evaluation strategy of perl
by mayaTheCat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |