Try:
 if(exists($hash{s}) and $hash{s} ne "T" __and__ $hash{s} ne "F") {

(underscore for emphasis, not code). Using the 'or' means that if $hash{s}
is "T", ($hash{s} ne "F") is actually true, so it continues with that block.

Cheers

Mark C

-----Original Message-----
From: Charles Lu [mailto:[EMAIL PROTECTED]]
Sent: 13 June 2001 15:53
To: [EMAIL PROTECTED]
Subject: Unexplainable behavior


The following snippet of code doesn't behave the way I want it to.  Yet i 
cannot see why?


$hash{s} = "T";


if(exists($hash{s}) and $hash{s} ne "T" or $hash{s} ne "F") {
        print "inside\n";
}
else{  print "outside\n"; }



the OUTPUT of this program prints   "inside".  But I want it to go INSIDE 
only if the key "s" exists in the hash, AND the value of $hash{s} DOES NOT 
equal "T" OR "F".    Can anyone suggest what I might be doing wrong here?  
By the way, even if I comment out the line that contain
$hash{s} = "T";,  the output still goes to "INSIDE".


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

Reply via email to