Next | Tricks of the Wizards | 88 |
Filter::Simple can help out with the parsing a little
Suppose we'd like to instrument each function to announce itself when it's called
It is sufficient to have each function call 'trace':
sub trace { ($package, $file, $line, $subr) = caller; my $depth = 0; 1 while defined caller(++$depth); my $indent = " " x ($depth - 2); local $" = ', '; print "$package\::$subr(@_)\n"; }
Our source filter will find this:
sub something { ...
And replace it with this:
sub something { &Trace::trace; ...
Next | Copyright © 2003 M. J. Dominus |