Next | Hook::LexWrap | 13 |
{ my $temporarily = wrap 'myfunc', ...;
myfunc(...); # Wrappers are called here } myfunc(...); # ... but not here
If called in scalar or list context, wrap returns a special object:
return bless sub{ $unwrap=1 }, 'Hook::LexWrap::Cleanup';
The object is stored in $temporarily
When $temporarily's lifetime is over, the object is destroyed
package Hook::LexWrap::Cleanup;
sub DESTROY { $_[0]->() }
This sets $unwrap to 1
The first thing that $imposter does is
if ($unwrap) { goto &$original }
Next | Copyright © 2003 M. J. Dominus |