|Perl: the Markov chain saw|
Re: Re: Anyone use "xor" in conditionals?by Excalibor (Pilgrim)
|on Jul 14, 2003 at 09:52 UTC||Need Help??|
Atually there's an easier way to write xor:
if ( (COND1 and not COND2) or ((not COND1) and COND2) )
This way the conditions are evaluated less times (I think this is the easier way of expressing 'xor' in terms of 'and', 'or' and 'not')
While I agree that xor is a useful operation, there aren't that many places where it applies, as many situations rule themselves out in an or comparison.
For example, unless you are trying to model the rainbow, if ( $raining or $sunny ) contemplates the whole weather (simplified) model. Admitedly, in some cases the possibility arises: just use it. But as CPAN demonstrates, there aren't so many examples.
Now, if you are implementing a parser, or any complicated enough state machine...