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


in reply to Re: A general method of locally overriding subroutines
in thread A general method of locally overriding subroutines

Update: this bug has now been fixed for perl-5.10 (change #27547), and I think it is likely the fix will make it into one of the next maintenance releases (5.8.9 or 5.8.10) as well.

So you will be able to write:

sub localise_and_call { my($fn, @args) = @_; my $stash = \%::; # assuming main package local @$stash{@args} = (sub { "changed" }) x @args; $fn->(@args); }

Hugo