| Next | Tricks of the Wizards | 101 |
In Part I, we saw a trace utility
It wrapped each function inside a tracing wrapper:
my $real_func = \&*$func_name;
*{$caller . "::$func_name"} = sub {
print "$func_name(@_)\n";
$real_func->(@_);
};
If $real_func depends on caller, it could get confused
It will notice that it was called from the wrapper, not from the real caller
Solution:
{$caller . "::$func_name"} = sub {
print "$func_name(@_)\n";
goto &$real_func;
};
| Next | ![]() |
Copyright © 2003 M. J. Dominus |