> if (defined $x and length $x)

So, is this the opposite?

 if (! defined $x and length $x)

or do I have to parenthesis
 if (! (defined $x and length $x))

-rkl

> On Oct 2, [EMAIL PROTECTED] said:
>
>>To recap, I want to test if a var is undefined or ''.
>>
>> if(undefined $x && length($x)==0)
>
> There IS no 'undefined' function in Perl, and you don't want to use &&,
> you'd want to use ||, since the empty string "" IS defined.
>
>   if (not defined($x) or length($x) == 0) {
>     # it's undef OR ""
>   }
>
> Or, do it the other way:
>
>   if (defined $x and length $x) {
>     # it's NOT undef, and it's NOT ""
>   }
>
> --
> Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
> RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
> <stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
> [  I'm looking for programming work.  If you like my work, let me know.  ]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to