You can write your handler for $SIG{__WARN__}
local $SIG{__WARN__} = sub { die $_[0] };
| [reply] [d/l] |
#!/usr/bin/perl -w
use strict;
#use warnings FATAL => qw{ uninitialized };
local $SIG{__WARN__} = sub { die "your variable is not defined!\n"; };
my $var;
print "the variable is $var\n";
thank you. | [reply] [d/l] |
Do realize that the warnings handle does not discriminate against the warning. If it installed, it will be called for every warning - be it from an uninitialized variable or something else. (Note that uninitialized variable is a bit of a misnomer, the trigger is an undefined value (not an undefined variable). Undefined values may happen because no value was every assigned to the variable, but it may also be an undefined value was assigned to it).
| [reply] |