in reply to Check Variables for NULL
Perl tries to make things as easy as possible for you and this is a good example.
In most cases, what you actually want is as simple as:
if ($value) { # $value contains something useful } else { # $value is "empty" }
(Note that the logic is reversed from your original example)
What we're doing here is checking the "truth" of $value. $value will be "false" if it contains any of the following values:
Any other value in $value will evaluate to "true".
This is all you need in most cases. There are a couple of "corner cases" that you sometimes have to consider:
"The first rule of Perl club is you do not talk about Perl club." -- Chip Salzenberg
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Check Variables for NULL
by jhourcle (Prior) on Feb 08, 2007 at 11:40 UTC |