Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: use warnings uninitialized to my own sub?

by iaw4 (Monk)
on Dec 08, 2010 at 08:53 UTC ( [id://875966]=note: print w/replies, xml ) Need Help??


in reply to Re: use warnings uninitialized to my own sub?
in thread use warnings uninitialized to my own sub?

works like a charm:
#!/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.

Replies are listed 'Best First'.
Re^3: use warnings uninitialized to my own sub?
by JavaFan (Canon) on Dec 08, 2010 at 11:50 UTC
    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).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://875966]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-24 23:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found