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