Skip to content

Commit da8c2d9

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 cf8bea5 commit da8c2d9

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
@@ -1025,14 +1025,19 @@ if the left operand is false, the right operand is not even evaluated.
10251025
Scalar or list context propagates down to the right operand if it
10261026
is evaluated.
10271027

1028+
C<&&> returns the last value evaluated (unlike C's C<&&>, which returns
1029+
0 or 1).
1030+
10281031
As an alternative to C<&&> when used for control flow, Perl provides the
10291032
C<and> operator (see L<below|/Logical And>).
10301033
The short-circuit behavior is identical. The precedence of C<"and"> is
10311034
much lower, however, so that you can safely use it after a list operator
10321035
without the need for parentheses.
10331036

1034-
=head2 C-style Logical Or
1037+
=head2 C-style Logical Or, Xor, and Defined Or
10351038
X<||> X<operator, logical, or>
1039+
X<^^> X<operator, logical, xor>
1040+
X<//> X<operator, logical, defined-or>
10361041

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

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

1065-
=head2 C-style Logical Xor
1066-
X<^^> X<operator, logical, xor>
1067-
10681070
Binary C<"^^"> performs a logical XOR operation. Both operands are
10691071
evaluated and the result is true only if exactly one of the operands is true.
10701072
Scalar or list context propagates down to the right operand.
10711073

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

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

10921091
$home = $ENV{HOME}
@@ -3860,6 +3859,24 @@ Here is a short, but incomplete summary:
38603859

38613860
Choose wisely.
38623861

3862+
=head2 C-style Logical Or
3863+
3864+
This section has been superceded by
3865+
L</C-style Logical Or, Xor, and Defined Or>. The heading is retained
3866+
only to prevent breaking any pre-existing links to it from outside.
3867+
3868+
=head2 C-style Logical Xor
3869+
3870+
This section has been superceded by
3871+
L</C-style Logical Or, Xor, and Defined Or>. The heading is retained
3872+
only to prevent breaking any pre-existing links to it from outside.
3873+
3874+
=head2 Logical Defined-Or
3875+
3876+
This section has been superceded by
3877+
L</C-style Logical Or, Xor, and Defined Or>. The heading is retained
3878+
only to prevent breaking any pre-existing links to it from outside.
3879+
38633880
=head1 APPENDIX
38643881

38653882
=head2 List of Extra Paired Delimiters

0 commit comments

Comments
 (0)