Re: very strange conditional problem

Discussion in 'Perl' started by J. Romano, Feb 21, 2004.

  1. J. Romano

    J. Romano Guest

    Kodeguru <> wrote in message news:<2SGZb.27067$>...
    >
    > # 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";
    >
    > #####------######
    >
    > 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.
    >
    > Anyone else have any ideas ?


    I have an idea, even though I do not know the exact reason why your
    code is not working as you'd expect.

    My thought is that your Perl interpreter doesn't like comparing a
    scalar to undef. Therefore, I suggest that, instead of comparing a
    scalar to see if it doesn't equal undef, try seeing if it is defined
    by using the "defined" keyword. Try changing the condition:

    if ($equip_row->[16] != undef)

    to this one:

    if (defined($equip_row->[16]))

    See if that works.

    Happy Perling!

    -- Jean-Luc
    J. Romano, Feb 21, 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. Kodeguru
    Replies:
    0
    Views:
    427
    Kodeguru
    Feb 20, 2004
  2. J. Romano
    Replies:
    0
    Views:
    451
    J. Romano
    Feb 21, 2004
  3. brewman
    Replies:
    0
    Views:
    1,431
    brewman
    Aug 28, 2003
  4. Kenneth McDonald

    Very, very strange problem with properties

    Kenneth McDonald, May 4, 2004, in forum: Python
    Replies:
    2
    Views:
    254
    Kenneth McDonald
    May 4, 2004
  5. Kodeguru

    very strange conditional problem

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

Share This Page