http://qs321.pair.com?node_id=562191


in reply to A general method of locally overriding subroutines

Is it me, or did everyone miss the simplest approach?

sub localize_and_call_fn { my ( $locals, $fn, @args ) = @_; if( @$locals ) { my ( $sym, @local ) = @$locals; local *$sym = sub { "changed" }; @local ? localize_and_call_fn( \@local, $fn, @args ) : $fn->( +@args ); } }

Makeshifts last the longest.