develooper Front page | perl.dbi.users | Postings from February 2001

Handeling undef data.

Thread Next
From:
Michelle Gerfort
Date:
February 22, 2001 05:13
Subject:
Handeling undef data.
Message ID:
3A95079E.39E09A60@teligent.se
Hi there!

I'm having a problem when using fetchrow_array().

The area of the code where the problem is, you find below.

while (@row = $sth->fetchrow_array() ) {
$len = @row;
for ($i = 0; $i < $len; $i++) {
    if ($row[$i] ne ""){
 print $row[$i] . "\t";
    }
    else{
 print "undefined value in row\t";
    }
}

I've read and understand that the fetchrow_array() returns undef when a
value from the database is NULL. With the code above I can identify that
a value is NULL and print out the line "undefined value in row". So far
so good.

My problem is that I not only get the line "undefined value in row"
printed, but I also get this:
Use of uninitialized value at
/home/www/docs/cgi-bin/CCDB_P/maintrep2.cgi line 137.

I wonder how I can get rid of these lines and what causes this print. Is
there a good way to take care of such undefined values, that I've missed
reading about?

(I do have O'REILY "Programming the Perl DBI)

Thank you in advance
Michelle Gerfort


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About