in reply to A general method of locally overriding subroutines
Are the functions to be overridden all in the same package? If they are, you can do the localisation with a single hash slice:
sub localise_and_call { my($fn, @args) = @_; my $stash = \%::; # assuming main package # I forgot the local here @$stash{@args} = (sub { "changed" }) x @args; $fn->(@args); }
Update: oops, doesn't work when I add the "local" where it's supposed to go. I'm not sure why not though, maybe a bug.
Update: now reported as bug #38710.
Hugo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A general method of locally overriding subroutines
by tmoertel (Chaplain) on Mar 11, 2006 at 16:56 UTC | |
|
Re^2: A general method of locally overriding subroutines
by hv (Prior) on Mar 20, 2006 at 10:59 UTC |