very strange conditional failure

K

Kodeguru

I just finished debugging a very strange problem, and was wondering if
any of you had ever seen it before. My code is very long, so I will only
post the interesting parts.

ok, so using DBD::Sybase and some other stuff, we do a select query on a
database and store the return like this:

#####------######

$sql = "SELECT blah blah blah";

$sth = $dbh->prepare();

$sth->execute();

while (my $equip_row = $sth->fetchrow_arrayref()){

# ....

# this line prints $equip_row->[16] is ([email protected])\n
# which is right
print "\$equip_row->[16] is ($equip_row->[16])\n";

if ($equip_row->[16] != undef){ # But then this test fails

# and this line doesn't print at all
print "$equip_row->[16] is not undef, so...\n";

# sends email
# ....

}
}


#####------######

Now if I change the line where the conditional is to

if ($equip_row->[16] =~ /\S+/) {

It works. Both debug lines print like they should and the emails get sent.

The code is working now, because I left it as a regex test, but this is
the craziest thing I've ever seen. I looked at it for hours, and I don't
think I'm missing anything stupid.

Anyone else have any ideas ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top