$ perl test.pl stacktrace leading to fourth at test.pl line 10 main::third() called at test.pl line 7 main::second() called at test.pl line 4 main::first() called at test.pl line 16 dying in fourth at test.pl line 14 main::fourth() called at test.pl line 10 main::third() called at test.pl line 7 main::second() called at test.pl line 4 main::first() called at test.pl line 16 $ cat -n test.pl 1 use Carp; 2 3 sub first { 4 second(); 5 } 6 sub second { 7 third(); 8 } 9 sub third { 10 fourth(); 11 } 12 sub fourth { 13 print STDERR Carp::longmess('stacktrace leading to fourth'); 14 Carp::confess("dying in fourth"); 15 } 16 first();