Perl Programming/Keywords/xor
< Perl Programming | Keywords
The xor keyword
[edit | edit source]xor is a logical exclusive OR operator that has a very low precedence, but is otherwise equivalent to ^. For logical reasons, it cannot short-circuit.
Syntax
[edit | edit source] VALUE xor VALUE
Examples
[edit | edit source]![](http://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Crystal_Clear_action_apply.png/20px-Crystal_Clear_action_apply.png)
$a = 5; # 0101
$b = 8; # 1000
print $a xor $b . ", " . $a ^ $b . "\n"; # Returns 5
prints only the first variable, as the first operator is valid:
5