Skip to content

Commit 6283f1e

Browse files
committed
perlop: Add detail about xor
Fixes #18565
1 parent 1c10605 commit 6283f1e

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
@@ -1530,9 +1530,15 @@ takes higher precedence.
15301530
Then again, you could always use parentheses.
15311531

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

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

0 commit comments

Comments
 (0)