@@ -1025,14 +1025,19 @@ if the left operand is false, the right operand is not even evaluated.
1025
1025
Scalar or list context propagates down to the right operand if it
1026
1026
is evaluated.
1027
1027
1028
+ C<&&> returns the last value evaluated (unlike C's C<&&>, which returns
1029
+ 0 or 1).
1030
+
1028
1031
As an alternative to C<&&> when used for control flow, Perl provides the
1029
1032
C<and> operator (see L<below|/Logical And>).
1030
1033
The short-circuit behavior is identical. The precedence of C<"and"> is
1031
1034
much lower, however, so that you can safely use it after a list operator
1032
1035
without the need for parentheses.
1033
1036
1034
- =head2 C-style Logical Or
1037
+ =head2 C-style Logical Or, Xor, and Defined Or
1035
1038
X<||> X<operator, logical, or>
1039
+ X<^^> X<operator, logical, xor>
1040
+ X<//> X<operator, logical, defined-or>
1036
1041
1037
1042
Binary C<"||"> performs a short-circuit logical OR operation. That is,
1038
1043
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:
1062
1067
1063
1068
Using C<"or"> for assignment is unlikely to do what you want; see below.
1064
1069
1065
- =head2 C-style Logical Xor
1066
- X<^^> X<operator, logical, xor>
1067
-
1068
1070
Binary C<"^^"> performs a logical XOR operation. Both operands are
1069
1071
evaluated and the result is true only if exactly one of the operands is true.
1070
1072
Scalar or list context propagates down to the right operand.
1071
1073
1072
- =head2 Logical Defined-Or
1073
- X<//> X<operator, logical, defined-or>
1074
-
1075
1074
Although it has no direct equivalent in C, Perl's C<//> operator is related
1076
1075
to its C-style "or". In fact, it's exactly the same as C<||>, except that it
1077
1076
tests the left hand side's definedness instead of its truth. Thus,
@@ -1085,8 +1084,8 @@ cannot). This is very useful for
1085
1084
providing default values for variables. If you actually want to test if
1086
1085
at least one of C<$x> and C<$y> is defined, use S<C<defined($x // $y)>>.
1087
1086
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
1090
1089
portable way to find out the home directory might be:
1091
1090
1092
1091
$home = $ENV{HOME}
@@ -3860,6 +3859,24 @@ Here is a short, but incomplete summary:
3860
3859
3861
3860
Choose wisely.
3862
3861
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
+
3863
3880
=head1 APPENDIX
3864
3881
3865
3882
=head2 List of Extra Paired Delimiters
0 commit comments