http://www.perlmonks.org?node_id=273927


in reply to Re: Anyone use "xor" in conditionals?
in thread Anyone use "xor" in conditionals?

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...

Best regards,

--
our $Perl6 is Fantastic;