Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Re: very strange conditional problem

Reply
Thread Tools

Re: very strange conditional problem

 
 
J. Romano
Guest
Posts: n/a
 
      02-21-2004
Kodeguru <(E-Mail Removed)> wrote in message news:<2SGZb.27067$(E-Mail Removed) et>...
>
> # this line prints $equip_row->[16] is ((E-Mail Removed))\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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Very, very strange problem with properties Kenneth McDonald Python 2 05-04-2004 04:19 AM
very strange conditional problem Kodeguru Perl Misc 9 02-21-2004 06:38 PM
Re: very strange conditional problem J. Romano Perl 0 02-21-2004 04:55 PM
very strange conditional failure Kodeguru Perl 0 02-20-2004 08:20 PM
Re: very very strange C++ NaN or memory management related problem brewman C++ 0 08-28-2003 10:35 PM



Advertisments