#!/usr/bin/env perl use 5.012; use warnings; # Convenience map for caller return my @ckeys = qw< pack file line sub has_args wantarray evaltext is_require hints bitmask hinthash >; sub Timeout { say "\n===> Signal caught! Call stack below <===="; for (my $i = 1; ;$i++) { my %call; @call{ @ckeys } = caller $i; last if not defined $call{pack}; # Done $call{wantarray} = $call{wantarray} ? 'LIST' : defined $call{wantarray} ? 'SCALAR' : 'VOID'; printf "%20s:%-4d %6s %s\n", @call{qw}; } } $SIG{"ALRM"} = \&Timeout; kill ALRM => $$; my @foo = one(); two(); sub one { kill ALRM => $$; } sub two { one('from_two'); } #### ===> Signal caught! Call stack below <==== /tmp/uaVo7iA.pl:26 SCALAR (eval) ===> Signal caught! Call stack below <==== /tmp/uaVo7iA.pl:31 SCALAR (eval) /tmp/uaVo7iA.pl:27 LIST main::one ===> Signal caught! Call stack below <==== /tmp/uaVo7iA.pl:31 SCALAR (eval) /tmp/uaVo7iA.pl:35 VOID main::one /tmp/uaVo7iA.pl:28 VOID main::two