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 

        if (exists ... and (this or that)) { ... }      

The first is only true when all three are true, the second is true when the
first and either the second or third thing are true.  It looks like Robin
has a posting about De Morgan's law which is the formal explanation of all
this Boolean algebra goop.  

Discrete math bites again.

Peter C.

> >$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
>     ($hash{s} ne "F")
>   ) { ... }
> 
> Change the parenthesization to suit your needs:
> 
>   if (exists ... and (this or that)) { ... }

Reply via email to