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. Advertisements

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. Shawn

    Very very strange. Major bug?

    Shawn, Feb 3, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    524
    Shawn
    Feb 4, 2004
  2. 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:
    737
    Raymond Hettinger
    Jul 27, 2003
  3. Kenneth McDonald

    Very, very strange problem with properties

    Kenneth McDonald, May 4, 2004, in forum: Python
    Replies:
    2
    Views:
    398
    Kenneth McDonald
    May 4, 2004
  4. shanx__=|;-

    very very very long integer

    shanx__=|;-, Oct 16, 2004, in forum: C Programming
    Replies:
    19
    Views:
    2,073
    Merrill & Michele
    Oct 19, 2004
  5. Abhishek Jha

    very very very long integer

    Abhishek Jha, Oct 16, 2004, in forum: C Programming
    Replies:
    4
    Views:
    738
    jacob navia
    Oct 17, 2004
  6. Peter

    Very very very basic question

    Peter, Feb 8, 2005, in forum: C Programming
    Replies:
    14
    Views:
    842
    Dave Thompson
    Feb 14, 2005
  7. olivier.melcher

    Help running a very very very simple code

    olivier.melcher, May 12, 2008, in forum: Java
    Replies:
    8
    Views:
    2,812
  8. Kodeguru

    very strange conditional problem

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