[Edinburgh-pm] Spot the bug

Aaron Crane perl at aaroncrane.co.uk
Wed May 1 07:56:54 PDT 2013


Miles Gould <miles at assyrian.org.uk> wrote:
> this problem would also have occurred if I'd just assigned the result
> to a variable:
>
> $ perl -E 'my $fred = 0 xor 1; say $fred'
> 0
>
> I conclude from this that Perl's xor operator has the wrong precedence, and
> one should always bracket it.

Another way of looking at it is that Perl's normal (high-precedence)
logical-XOR operator is inexplicably absent.

The obvious choice for such an operator would be "^^".  AFAICT,
there's no technical impediment to adding it, in that (I believe) it's
impossible for a term to begin with "^", and therefore any occurrence
of the string "^^" in operator position in Perl source must currently
be a syntax error.  I think it would be reasonably easy to add, too,
if someone were interested in hacking it into the Perl core.  Probably
worth speaking to p5p before investing too much time in it, mind.

--
Aaron Crane ** http://aaroncrane.co.uk/


More information about the Edinburgh-pm mailing list