Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: uninitialized value

by count0 (Friar)
on Jan 22, 2002 at 23:49 UTC ( #140717=note: print w/replies, xml ) Need Help??


in reply to uninitialized value

As a preventative measure, this is a good rule of thumb to follow:
Whenever you aren't sure if a variable has been assigned a value, give it one explicitly =)

The || operator is very useful here.
Examples:
my $variable = $some_unknown_input || 'default'; my $foo = (defined $input ? $input : '');
In the first example, if $some_unknown_input is not a true value, $variable will be assigned 'default'.
In the second example, if $input is undefined (note this is not necessarily the same as being non-true, as in the first example), it is assigned an empty string.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://140717]
help
Chatterbox?
[GotToBTru]: ugh. Thanks Corion
[shmem]: meh. setting up a SIG{__DIE__} before loading Net::SSLeay still triggers Can't locate object method "tid" via package "threads" at /usr/share/perl/5. 20/XSLoader.pm
[choroba]: setting in a BEGIN block?
[shmem]: choroba, yes

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2017-07-26 15:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (396 votes). Check out past polls.