Don't ask to ask, just ask | |
PerlMonks |
Re: uninitialized valueby count0 (Friar) |
on Jan 22, 2002 at 23:49 UTC ( [id://140717]=note: print w/replies, xml ) | Need Help?? |
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: 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.
In Section
Seekers of Perl Wisdom
|
|