Next | Tricks of the Wizards | 186 |
Occasionally-asked question:
"How can I emulate the behavior of the Bourne shell -x option?"
Here's one way:
package Devel::Trace;
sub DB::DB { my ($p, $f, $l) = caller; my $code = \@{"::_<$f"}; print STDERR ">> $f($l) $code->[$l]"; }
Now perl -d:Trace sample.pl prints out:
>> sample.pl(1) for (1 .. ($ARGV[0] || 12)) { >> sample.pl(2) next unless $_ % 12; >> sample.pl(3) print ""; >> sample.pl(1) for (1 .. ($ARGV[0] || 12)) { (etc.)
Next | Copyright © 2003 M. J. Dominus |