Not really sure what you're looking for, but maybe something like the Perl debugger's tracing facility?
For example, with a silly little program like this
#!/usr/local/bin/perl
sub add {
return $_[0] + $_[1];
}
sub result {
my $sum = shift;
$sum = add($sum, shift) while @_;
return $sum;
}
print result(@ARGV);
running it as follows under the debugger, would produce:
$ PERLDB_OPTS="NonStop AutoTrace frame=29" perl -d ./silly.pl 2 3 4
Package ./silly.pl.
13: print result(@ARGV);
in @=main::result(2, 3, 4) from ./silly.pl:13
8: my $sum = shift;
9: $sum = add($sum, shift) while @_;
in $=main::add(2, 3) from ./silly.pl:9
4: return $_[0] + $_[1];
scalar context return from main::add: 5
in $=main::add(5, 4) from ./silly.pl:9
4: return $_[0] + $_[1];
scalar context return from main::add: 9
10: return $sum;
list context return from main::result:
0 9
9
(Note that the technique to set environment variables (PERLDB_OPTS) depends on the shell being used.)
This shows step by step what is being executed.
There are also less verbose modes. See perldebug for the meaning of the debugging options like frame etc.
|