use 5.030; use warnings; my @subrefs = (); my $i = 0; for (1..3) { $i++; push @subrefs, sub { print $i; }; } for (@subrefs) { $_->(); }