northwestdev has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks, I have the following code
my $reissue="reissue"; my $yes="Y"; my $no="N"; my $phase =1; my $dateMatch=$no; my $NPpending="NPpending"; my $matchRating="matchRating"; my $HITstatus=$reissue; if (($dateMatch == $yes) && ($phase == 1)) { $HITstatus=$NPpending; } if ($dateMatch == $yes) { $HITstatus=$matchRating; } print $HITstatus."<br>\n"; print $dateMatch."<br>\n"; =============================== Here's the output: matchRating N
I'm expecting to see reissue instead of matchRating. What am I doing incorrectly?

Replies are listed 'Best First'.
Re: Unexpcted answer
by ikegami (Patriarch) on Jun 08, 2009 at 13:31 UTC
    Use use strict; use warnings;! The warnings you are getting (Argument "Y" isn't numeric in numeric eq (==)) should be the tip off. You're using numerical comparison to compare strings. Use "eq" instead.
Re: Unexpcted answer
by Anonymous Monk on Jun 08, 2009 at 13:29 UTC
    Following this advice I modified your program with
    use strict; use warnings;
    extra output was
    Argument "Y" isn't numeric in numeric eq (==) at - line 14. Argument "N" isn't numeric in numeric eq (==) at - line 14.
    Use eq to commpare strings, == for numbers. See perlintro, perlop.