When it comes to undefined variables that would trigger a warning under -w
, you can use a handler to trap the pseudo-signal
__WARN__
like this:
$SIG{__WARN__} = sub {
for ( $_[0] ) {
/Use of uninitialized value/ && do { # promote warning to a fatal die $_; };
# other warning cases to catch could go here;
warn $_; }
};