How can I get a call stack listing in Perl?

You can use Devel::StackTrace.

use Devel::StackTrace;
my $trace = Devel::StackTrace->new;
print $trace->as_string; # like carp

It behaves like Carp’s trace, but you can get more control over the frames.

The one problem is that references are stringified and if a referenced value changes, you won’t see it. However, you could whip up some stuff with PadWalker to print out the full data (it would be huge, though).

Leave a Comment