It's worth mentioning that there are a few different kinds of nothings.
The ones I know that apply to ordinary (scalar) variables are
the number zero, the empty string, with or without a null character
to terminate it, boolean false, and undef, the value of variables that
don't exist yet. A lot of the time they are implicitly converted back
and forth, but sometimes you need to know the difference:
if ($var == 0) {numerical zero}
if ($var eq "") {empty string}
if (!$var) {boolean false}
if (! defined($var) ) {undef}
On Tue, 17 Jul 2001, Mooney Christophe-CMOONEY1 wrote:
> Exactly like that, except using 'eq' instead of '=='.
> A slightly easier way, though, would be to say
>
> if (!$something) { ... blah blah ... }
>
> Since $something will return false in a boolean context (if it is empty)
>
> -----Original Message-----
> From: Tyler Longren [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 17, 2001 12:56 PM
> To: Perl Beginners
> Subject: if something equals nothing
>
>
> How do I do:
> if ($something == "") {
> # do something
> }
>
> in perl?
>
> Thanks,
> Tyler
>
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]