my $x; BEGIN { $x = 0 } my $f = sub { $x }; ++$x; print $f->(); #### for (1..2) { my $x = $_; print sub { $x }->(); }