[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> writes:
} I have found something which strikes me as strange and wonder if anyone can
} shed light on it?
} 
[deletia]
} 
} Why does (/foo | bar/) work in this way? Neither (/foo & bar/) nor (/foo ^
} bar/) nor (/foo && bar/) nor (/foo || bar/) behave other than as expected.
} Is this:
} 
}         a)      a happy quirk of Unix Perl?
}         b)      a built-in undocumented property of Unix Perl?
}         c)      something unique to MacPerl?
}         d)      just something I have missed in the documentation?

The answer is d).  Inside a regular expression, | is the alternation
operator. It's not being interpreted as a bitwise or because it's in a
regexp. You are asking "match either foo or bar" in the regexp you give
above. See the perlre.html page that comes with MacPerl 5.x.

} 
} Certainly it is extremely useful -- but is it safe?
} 
} Alan
} 
} 
} 
---
--------
Paul J. Schinder
NASA Goddard Space Flight Center,
Code 693, Greenbelt, MD 20771 USA
schinder@pjstoaster.pg.md.us