RE: RE: Unexplainable behavior

2001-06-13 Thread Peter Cornelius
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

RE: Unexplainable behavior

2001-06-13 Thread Robin Lavallee (LMC)
> -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} =

Re: Unexplainable behavior

2001-06-13 Thread Jos Boumans
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

Re: Unexplainable behavior

2001-06-13 Thread Jeff 'japhy' Pinyan
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

RE: Unexplainable behavior

2001-06-13 Thread mark crowe (JIC)
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

Re: Unexplainable behavior

2001-06-13 Thread David M. Lloyd
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