Skip to content

Commit 943490c

Browse files
committed
perlop: Add detail about xor
Fixes #18565
1 parent 78335c4 commit 943490c

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pod/perlop.pod

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,9 +1522,15 @@ takes higher precedence.
15221522
Then again, you could always use parentheses.
15231523

15241524
Binary C<"xor"> returns the logical exclusive disjunction of the two
1525-
surrounding expressions.
1526-
It cannot short-circuit (of course).
1527-
1525+
surrounding expressions. That means it returns C<true> if either, but
1526+
not both, are true. It's equivalent to C<^^> except for it having very
1527+
low precedence. It cannot short-circuit (of course). It tends to be
1528+
used to verify that two mutually-exclusive conditions are actually
1529+
mutually exclusive. For example, in Perl's test suite, we might want to
1530+
test that a regular expression pattern can't both match and not match,
1531+
for otherwise it would be a bug in our pattern matching code.
1532+
1533+
($x =~ qr/$pat/ xor $x !~ qr/$pat/) or die;
15281534

15291535
=head2 C Operators Missing From Perl
15301536
X<operator, missing from perl> X<&> X<*>

0 commit comments

Comments
 (0)