Skip to content

Commit e90d99a

Browse files
committed
perlop: Combine equal precedence ops into same section
The design of this pod is each section is for all operators of the same precedence. This was being violated
1 parent da1efd5 commit e90d99a

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

pod/perlop.pod

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,14 +1017,19 @@ if the left operand is false, the right operand is not even evaluated.
10171017
Scalar or list context propagates down to the right operand if it
10181018
is evaluated.
10191019

1020+
C<&&> returns the last value evaluated (unlike C's C<&&>, which returns
1021+
0 or 1).
1022+
10201023
As an alternative to C<&&> when used for control flow, Perl provides the
10211024
C<and> operator (see L<below|/Logical And>).
10221025
The short-circuit behavior is identical. The precedence of C<"and"> is
10231026
much lower, however, so that you can safely use it after a list operator
10241027
without the need for parentheses.
10251028

1026-
=head2 C-style Logical Or
1029+
=head2 C-style Logical Or, Xor, and Defined Or
10271030
X<||> X<operator, logical, or>
1031+
X<^^> X<operator, logical, xor>
1032+
X<//> X<operator, logical, defined-or>
10281033

10291034
Binary C<"||"> performs a short-circuit logical OR operation. That is,
10301035
if the left operand is true, the right operand is not even evaluated.
@@ -1054,16 +1059,10 @@ It would be even more readable to write that this way:
10541059

10551060
Using C<"or"> for assignment is unlikely to do what you want; see below.
10561061

1057-
=head2 C-style Logical Xor
1058-
X<^^> X<operator, logical, xor>
1059-
10601062
Binary C<"^^"> performs a logical XOR operation. Both operands are
10611063
evaluated and the result is true only if exactly one of the operands is true.
10621064
Scalar or list context propagates down to the right operand.
10631065

1064-
=head2 Logical Defined-Or
1065-
X<//> X<operator, logical, defined-or>
1066-
10671066
Although it has no direct equivalent in C, Perl's C<//> operator is related
10681067
to its C-style "or". In fact, it's exactly the same as C<||>, except that it
10691068
tests the left hand side's definedness instead of its truth. Thus,
@@ -1077,8 +1076,8 @@ cannot). This is very useful for
10771076
providing default values for variables. If you actually want to test if
10781077
at least one of C<$x> and C<$y> is defined, use S<C<defined($x // $y)>>.
10791078

1080-
The C<||>, C<//> and C<&&> operators return the last value evaluated
1081-
(unlike C's C<||> and C<&&>, which return 0 or 1). Thus, a reasonably
1079+
The C<||>, C<^^> and C<//> operators return the last value evaluated
1080+
(unlike C's C<||> which returns 0 or 1). Thus, a reasonably
10821081
portable way to find out the home directory might be:
10831082

10841083
$home = $ENV{HOME}
@@ -3852,6 +3851,24 @@ Here is a short, but incomplete summary:
38523851

38533852
Choose wisely.
38543853

3854+
=head2 C-style Logical Or
3855+
3856+
This section has been superceded by
3857+
L</C-style Logical Or, Xor, and Defined Or>. The heading is retained
3858+
only to prevent breaking any pre-existing links to it from outside.
3859+
3860+
=head2 C-style Logical Xor
3861+
3862+
This section has been superceded by
3863+
L</C-style Logical Or, Xor, and Defined Or>. The heading is retained
3864+
only to prevent breaking any pre-existing links to it from outside.
3865+
3866+
=head2 Logical Defined-Or
3867+
3868+
This section has been superceded by
3869+
L</C-style Logical Or, Xor, and Defined Or>. The heading is retained
3870+
only to prevent breaking any pre-existing links to it from outside.
3871+
38553872
=head1 APPENDIX
38563873

38573874
=head2 List of Extra Paired Delimiters

0 commit comments

Comments
 (0)