9.5. Confession Is Good for the Soul

Sometimes your program dies not in your code but in some module you call—suicide by association if you will. A module that wants to die is supposed to call Carp::croak instead, because croak reports the location of death as the place the module function was called, not the line of code in the module function containing the croak call.

Some modules don't do this. Either they call die, or they call another module that croaks; either way, you're left with an error message that doesn't tell you which line of your program caused its untimely demise.

If this happens, here's a quick way to force it to 'fess up. Near the beginning of your program, insert the following:

 use Carp qw(cluck verbose); $SIG{__DIE__} = ...

Get Perl Debugged now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.