Benjamin Schieder


2011 May 27 | 2 comments

How to easily get a Perl stack trace? Like this:

my $i = 1;
print "Stack Trace:\\n";
while ( (my @call_details = (caller($i++))) ){
print $call_details[1].":".$call_details[2]." in function ".$call_details[3]."\\n";


Category: blog

Tags: Tech


From: schirsch
2011-05-28 13:15:43 +0200

Or use the routines (longmes() or so) from the Carp modules that produce way more readable and useful stack traces..

From: blindcoder
2011-05-29 10:27:58 +0200

Yeah, I've seen the Carp modules, too, while searching for a stack tracer for Perl.
Problem is: I needed this trace on a machine with no internet connectivity (yes, these things still exist today) on a Solaris X machine.
I didn't know of an easy way to get the Carp module and all dependencies loaded in an easy way, and caller() gave me enough information for the problem I had.

Post a comment

All comments are held for moderation; basic HTML formatting is accepted.

Name: (required)
E-mail: (required, not published)
Website: (optional)