< Perl Programming < Keywords

The code
The xor keyword
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
VALUE xor VALUE
Examples

$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
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.