Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: A general method of locally overriding subroutines

by hv (Parson)
on Mar 20, 2006 at 10:59 UTC ( #537915=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://537915]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2020-10-25 03:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (248 votes). Check out past polls.

    Notices?