http://www.perlmonks.org?node_id=640338


in reply to Forcing stack trace?

Can I tell perl to produce a stack trace, even when the program doesn't use carp, cluck, et al?
i'm not sure what do you mean by that.
use Carp qw(longmess); print longmess();
works for me.

Replies are listed 'Best First'.
Re^2: Forcing stack trace?
by Anonymous Monk on Sep 21, 2007 at 11:56 UTC
    From what I understand, stack trace can be printed if we use the Carp module (e.g. confess). But suppose other people's code just use die() and not use Carp at all?
      You can override the global __DIE__ handler something like (untested):
      use Carp; $SIG{ __DIE__ } = sub { Carp::confess( @_ ) };

      See perlvar for more info on %SIG.