our $bar = "BBB"; sub foo { print "orig foo (bar=$bar)\n" } sub bar { print "orig bar (bar=$bar)\n" } { local *foo = sub { print "local foo (bar=$bar)\n"; }; local *bar; # this also clears $bar! sub quz { foo(); eval { bar(); 1 } or warn "calling bar failed: $@"; } sub baz { *bar = sub { print "local bar (bar=$bar)\n"; }; } quz(); # first call to quz (OOPS, $bar is undef!) baz(); # first call to baz quz(); # second call to quz (OOPS, $bar is still undef!) }