Re: Undef value trouble

2005-02-19 Thread Peter Scott
In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Wiggins d'Anconia) writes:
>Lawrence Statton wrote:
>> while ( defined ( my ($pid) = $sth->fetchrow_array ) ) {
>0 in a scalar variable is NOT equal to undef; however both are false. 
>The above specifically checks for definedness, as opposed to truth.

0 compares as numerically equal to undef.  However, if warnings
are on, and of course, warnings should be on, there will be a
warning generated, so this comparison is rarely a good idea.

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/

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




Re: Undef value trouble

2005-02-18 Thread Wiggins d'Anconia
Lawrence Statton wrote:
Hello there!
As we know and as Larry Wall said in a Camel-book 0 in scalar variable 
is equal to undef. I have in my database PID columns with unique values. 
When I try to perform this column data by "while my $pid = 
$sth->fetchrow_array()" I lost one record because it has the "0" value. 
How could I pass this situation?


while ( defined ( my ($pid) = $sth->fetchrow_array ) ) {
} 

This hits to the heart of the question and whether or not that is a typo 
in the original message. Specifically--

0 in a scalar variable is NOT equal to undef; however both are false. 
The above specifically checks for definedness, as opposed to truth.

I thought I would highlight this since it is a fairly tricky concept in 
Perl (and programming in general).

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
	Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.

http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Undef value trouble

2005-02-18 Thread Lawrence Statton
> Hello there!
> 
> As we know and as Larry Wall said in a Camel-book 0 in scalar variable 
> is equal to undef. I have in my database PID columns with unique values. 
> When I try to perform this column data by "while my $pid = 
> $sth->fetchrow_array()" I lost one record because it has the "0" value. 
> How could I pass this situation?
> 

while ( defined ( my ($pid) = $sth->fetchrow_array ) ) {
} 

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.

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




Undef value trouble

2005-02-18 Thread Nicolay Vasiliev
Hello there!
As we know and as Larry Wall said in a Camel-book 0 in scalar variable 
is equal to undef. I have in my database PID columns with unique values. 
When I try to perform this column data by "while my $pid = 
$sth->fetchrow_array()" I lost one record because it has the "0" value. 
How could I pass this situation?

Thanks in advance.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]