a tumblelog
Wed 14 Aug 2019

Getting a stack trace in Perl on die

In the afternoon I was debugging a Perl program that died in a function; I tried to call a method on an unblessed reference.

Because I wanted to know which part of the code had called this function I defined a sig handler for __DIE__ as follows:

use Carp;
$SIG{ __DIE__ } = sub {
    Carp::confess( @_ );

And I got a nice stack trace which made it possible to fix this bug within a few minutes.