Alex Rivera | Logout

How can you get Perl to stop when referencing an undef value?

Asked 2008-09-16T22:30:07.437
15

How do you get Perl to stop and give a stack trace when you reference an undef value, rather than merely warning? It seems that use strict; isn't sufficient for this purpose.

Edit
Report

1 Answer

20
use warnings FATAL => 'uninitialized';

use Carp ();
$SIG{__DIE__} = \&Carp::confess;

The first line makes the warning fatal. The next two cause a stack trace when your program dies.

See also man 3pm warnings for more details.

answered 2008-09-16T22:32:25.853

Your Answer