$ perl -Mstrict -E '{ my %foo = (test => 1); sub test { print $foo{test} } } my $sub = \&test; $sub->()' 1