perl version: 5.005_03, 5.6.0
This is not a bug! I mistakenly assumed xor precedence was higher than '=' and was wrong!
perl 'xor' is wonky: % cat p #!/usr/bin/perl for (0..3) { my ($a,$b) = (($_&1),($_&2)>>1); my $c = ($a xor $b); print "($a xor $b) is $c\n"; } for (0..3) { my ($a,$b) = (($_&1),($_&2)>>1); my $c = $a xor $b; print "$a xor $b is $c\n"; } % p (0 xor 0) is (1 xor 0) is 1 (0 xor 1) is 1 (1 xor 1) is 0 xor 0 is 0 1 xor 0 is 1 0 xor 1 is 0 1 xor 1 is 1 The "($a xor $b)" works by returning 1:"" The "$a xor $b" seems completely wonky, it just returns $a: % perl -e 'print 42 xor 9;' 42 Ah! It seems to be treating it like the short circuit or: % perl -e 'print (1 xor 0),"...blah blah\n";' 1 % perl -e 'print (0 xor 0),"...blah blah\n";' And even: % perl -e 'print "hi: ",(0 xor 3)," ...blah blah\n";' hi: 1 ...blah blah % perl -e 'print "hi: ",(1 xor 3)," ...blah blah\n";' hi: ...blah blah However: % man perlop ... Binary "xor" returns the exclusive-OR of the two surrounding expressions. It cannot short circuit, of course. ...