foreach (0, 1) { my $i = $_; sub my_print () { print $i; } my_print; }