very strange conditional failure

Discussion in 'Perl' started by Kodeguru, Feb 20, 2004.

  1. Kodeguru

    Kodeguru Guest

    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 ()\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 ?

    --
    Michael O'Malley Jr.
    President
    Pillar Open Source.
    Kodeguru, Feb 20, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J. Romano
    Replies:
    0
    Views:
    483
    J. Romano
    Feb 21, 2004
  2. J. Romano
    Replies:
    0
    Views:
    451
    J. Romano
    Feb 21, 2004
  3. Raymond Arthur St. Marie II of III

    very Very VERY dumb Question About The new Set( ) 's

    Raymond Arthur St. Marie II of III, Jul 23, 2003, in forum: Python
    Replies:
    4
    Views:
    453
    Raymond Hettinger
    Jul 27, 2003
  4. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    1,594
    Merrill & Michele
    Oct 19, 2004
  5. Kodeguru

    very strange conditional problem

    Kodeguru, Feb 21, 2004, in forum: Perl Misc
    Replies:
    9
    Views:
    100
    Kodeguru
    Feb 21, 2004
Loading...

Share This Page