So wouldn't you expect the more clingy '||' to work here? It doesn't, I
checked. If operator precedence was the problem then using the higher
precedence operator should work. I think this is a logic flaw. Charles
really meant
if (exists ... and this and that) { ... }
not
i
> -Original Message-
> From: Charles Lu [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, June 13, 2001 10:53 AM
> 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} =
untested, but here's my theory:
you're having precedence problems, try parenthesizing!
ie,
if( exists($hash{s}) and ( ($hash{s} ne "T") or ($hash{s} ne "F") ) ) {
hth,
Jos Boumans
Charles Lu wrote:
> The following snippet of code doesn't behave the way I want it to. Yet i
> cannot see wh
On Jun 13, Charles Lu said:
>$hash{s} = "T";
>
>
>if(exists($hash{s}) and $hash{s} ne "T" or $hash{s} ne "F") {
> print "inside\n";
>}
>else{ print "outside\n"; }
'or' is less "clingy" than 'and'. Therefore, your code parses like:
if (
(exists $hash{s} and $hash{s} ne "T")
or
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:[EM
On Wed, 13 Jun 2001, Charles Lu wrote:
> 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"; }
This exp