my $cause = 'PARSER'; eval { local $SIG{__DIE__} = sub { $cause = caller ? 'EXPLICIT' : 'INTERNAL'}; $do_something(); }; print $cause if $@;