>if (defined $x and length $x)
>
>So, is this the opposite?
>
>if (! defined $x and ! length $x)
I don't think so. It's basic Aristotelian logic and can be determined
by truth tables or testing. Questions are mere conjecture :)
The negative of a statement, A, is: not A. That can be writte
On Thu, Oct 02, 2003 at 07:41:41PM -0700, [EMAIL PROTECTED] wrote:
> unless understood, how about this.
>
> if (defined $x and length $x)
>
> So, is this the opposite?
>
> if (! defined $x and ! length $x)
Nope; now you've got a boolean logic problem.
Either of these would work, but unless() is
unless understood, how about this.
if (defined $x and length $x)
So, is this the opposite?
if (! defined $x and ! length $x)
-rkl
> On Thu, Oct 02, 2003 at 07:03:02PM -0700, [EMAIL PROTECTED] wrote:
>> > if (defined $x and length $x)
>>
>> So, is this the opposite?
>>
>> if (! defined $x and
On Thu, Oct 02, 2003 at 07:03:02PM -0700, [EMAIL PROTECTED] wrote:
> > if (defined $x and length $x)
>
> So, is this the opposite?
>
> if (! defined $x and length $x)
Nope; you've got a precedence problem.
unless( defined $x and length $x ) { }
--
Steve
--
To unsubscribe, e-mail: [EMAIL
> 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)
>
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) =
t; -Original Message-
>> From: James Edward Gray II [mailto:[EMAIL PROTECTED]
>> Sent: Thursday, October 02, 2003 5:20 PM
>> To: [EMAIL PROTECTED]
>> Cc: [EMAIL PROTECTED]
>> Subject: Re: Testing Uninitialized Vars
>>
>>
>> On Thursday, Octob
On Thursday, October 2, 2003, at 07:23 PM, LoBue, Mark wrote:
-Original Message-
From: James Edward Gray II [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 02, 2003 5:20 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: Testing Uninitialized Vars
On Thursday, October 2, 2003
> -Original Message-
> From: James Edward Gray II [mailto:[EMAIL PROTECTED]
> Sent: Thursday, October 02, 2003 5:20 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: Testing Uninitialized Vars
>
>
> On Thursday, October 2, 2003, at 07:08
On Thursday, October 2, 2003, at 07:08 PM, [EMAIL PROTECTED] wrote:
you mean $x=0; would be false?
Yep.
James
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
you mean $x=0; would be false?
> On Thursday, October 2, 2003, at 06:29 PM, [EMAIL PROTECTED] wrote:
>
>> Are you saying this would do everything that I want?
>>
>> #I'm considering undefined var and '' and 0s are the same thing.
>> if($x) ... true - do_something
>
> I said it would, if you don't
On Thursday, October 2, 2003, at 06:29 PM, [EMAIL PROTECTED] wrote:
Are you saying this would do everything that I want?
#I'm considering undefined var and '' and 0s are the same thing.
if($x) ... true - do_something
I said it would, if you don't mind 0 being false.
James
--
To unsubscribe, e-
Are you saying this would do everything that I want?
#I'm considering undefined var and '' and 0s are the same thing.
if($x) ... true - do_something
-rkl
> On Thursday, October 2, 2003, at 05:09 PM, [EMAIL PROTECTED] wrote:
>
>>> if ( ! defined $x )
>>
>> I read up on defined and undefined. But
On Thursday, October 2, 2003, at 05:09 PM, [EMAIL PROTECTED] wrote:
if ( ! defined $x )
I read up on defined and undefined. But I'm looking for a test that
will
this return true or false to a var condition:
perldoc -f defined
perldoc -f undef
The second is a little different than what you thin
> if ( ! defined $x )
I read up on defined and undefined. But I'm looking for a test that will
this return true or false to a var condition:
...
sub isNULL
{
return undefined $_[0] && $_[0] eq '' $_[0] eq "";
}
# my goal is all three return the same as
# my proposed sub isNULL()
my $x;
On Thursday, October 2, 2003, at 04:25 PM, [EMAIL PROTECTED] wrote:
I wan to write a sub return true or false if the var was initialized.
We can do that, but I really don't think we need a sub for it, since
there is a built-in.
Can someone correct this sub or is it good?
No, I wouldn't call it
I wan to write a sub return true or false if the var was initialized.
Can someone correct this sub or is it good?
...
if(isNULL($x) { print "it is null\n");
else { print "it is NOT null\n");
...
sub isNULL
{
return $_[0] =~ //
}
thanks,
-rkl
--
To unsubscribe, e-mail: [EMAIL PR
17 matches
Mail list logo