Saturday, July 16, 2022

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

Issue

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.


Solution

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 By - cjm
Answer Checked By - David Marino (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.