# create a block to isolate the sub { local *foo = sub { print "foo\n"; }; # this works foo(); } # this does not work foo();