diff options
Diffstat (limited to 'pod/perlop.pod')
-rw-r--r-- | pod/perlop.pod | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod index 5dd86eb125..aaa86de04a 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -510,10 +510,11 @@ Although it has no direct equivalent in C, Perl's C<//> operator is related to its C-style or. In fact, it's exactly the same as C<||>, except that it tests the left hand side's definedness instead of its truth. Thus, C<$a // $b> is similar to C<defined($a) || $b> (except that it returns the value of C<$a> -rather than the value of C<defined($a)>) and is exactly equivalent to -C<defined($a) ? $a : $b>. This is very useful for providing default values -for variables. If you actually want to test if at least one of C<$a> and -C<$b> is defined, use C<defined($a // $b)>. +rather than the value of C<defined($a)>) and yields the same result than +C<defined($a) ? $a : $b> (except that the ternary-operator form can be +used as a lvalue, while C<$a // $b> cannot). This is very useful for +providing default values for variables. If you actually want to test if +at least one of C<$a> and C<$b> is defined, use C<defined($a // $b)>. The C<||>, C<//> and C<&&> operators return the last value evaluated (unlike C's C<||> and C<&&>, which return 0 or 1). Thus, a reasonably |