my @d; for (my $i = 0; $i<3; $i++) { my $j=$i; push @d, sub { print "$j\n" }; }