Re: very strange conditional problem
From: J. Romano (jl_post_at_hotmail.com)
Date: 02/21/04
- Next message: Ben Morrow: "Re: Can Perl do this task???"
- Previous message: at: "Can Perl do this task???"
- In reply to: Kodeguru: "very strange conditional problem"
- Next in thread: J. Romano: "Re: very strange conditional problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 21 Feb 2004 08:14:52 -0800
Kodeguru <newz@xoftware.org> wrote in message news:<2SGZb.27067$ac.4342902@news4.srv.hcvlny.cv.net>...
>
> # this line prints $equip_row->[16] is (some@email.address)\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
- Next message: Ben Morrow: "Re: Can Perl do this task???"
- Previous message: at: "Can Perl do this task???"
- In reply to: Kodeguru: "very strange conditional problem"
- Next in thread: J. Romano: "Re: very strange conditional problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|