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