Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: uninitialized value

by count0 (Friar)
on Jan 22, 2002 at 23:49 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://140717]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (1)
As of 2024-04-24 14:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found