[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Bit-wise logical operators in MacPerl



Alan Fry <ajf@afco.demon.co.uk> wrote
>I have found something which strikes me as strange and wonder if anyone can
>shed light on it?
>
> deletia
>
>Suppose "foo" were "A" and "bar" were "B". The bit-wise operator | would
>(presumably) take that to mean 65 | 66 would it not? But 65 | 66 == 67,
>which is certainly not "true".
>
> deletia
>
>Alan

Hello,
      Other posters have pointed out that within a regexp the '|' symbol
is used to separate potential pattern matches. However, I'd like to draw
attention to your contention that '65 | 66 == 67, which is certainly not
"true".'. According to the Camel p. 6, "In Perl, the rule is very simple: a
value is true if it isn't the null string ('') or 0 or "0"." Hence I would
contend that 67 is "true", since it's non-zero.

Bob

___________________________________________________________
   Bob Wilkinson, Perl Programmer, Pindar plc
Tel: +44 (0)1904 613040    Email: B.Wilkinson@pindar.co.uk
Fax: +44 (0)1904 613110    URL: http://www.pindar.co.uk/~bw
___________________________________________________________
    The views expressed herein are mine, and are not 
          necessarily shared by my employer.
___________________________________________________________