use strict; use warnings; use Carp; use constant ERR_BACKTRACE => 1; BEGIN { if (ERR_BACKTRACE) { *CORE::GLOBAL::warn = \&Carp::cluck; *CORE::GLOBAL::die = \&Carp::confess; } } sub t2{ warn "warn with trace"; } sub t1 { t2(21,22,23); die "die with trace"; } t1(11,12,13);