in reply to Making lexically-scoped ref available to non-OO subs in another package
Have you heard of local? See source of Web::Scraper, the jist of which is
sub my_outer(&) { my( $callback ) = @_; my $stash = {}; no warnings 'redefine'; ## closure local *my_inners = sub { ... $stash ... }; local *foo = sub { ... $stash ... }; local *result = sub { ... $stash ... }; return $callback->( $stash ); }
|
|---|