sub foo { my $shared_with_all_recur = ...; local *_recur = sub { ... _recur(...); ... }; _recur(...); }