| Next | Tricks of the Wizards | 187 |
package Devel::Dumpcode;
sub DB::DB { } # Do nothing special
sub main::source_of_function {
my $package = caller;
$function = $package . '::' . shift();
my ($file, $start, $end) =
$DB::sub{$function} =~ /(.*):(\d+)-(\d+)/;
@{"::_<$file"}[$start..$end];
}
Now the program can do
print source_of_function('foo')
to print out the source of function foo
Print code to file, invoke editor, reload, eval
| Next | ![]() |
Copyright © 2003 M. J. Dominus |