Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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.
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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://140717]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2017-02-22 19:53 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (335 votes). Check out past polls.