use Devel::StackTrace; my $trace = Devel::StackTrace->new; print $trace->as_string; # like carp
Devel::Trace print out each line before it is executed (like sh -x).