diff options
author | Dan Book <grinnz@grinnz.com> | 2020-04-28 15:38:24 -0400 |
---|---|---|
committer | Sawyer X <xsawyerx@cpan.org> | 2020-05-21 00:45:36 +0300 |
commit | db6b975f9cb8d5cea11d22f5f915e92c22c51889 (patch) | |
tree | 03af41d6e41123b6b5a2e655c15f7ef0e48298b2 /pod/perlop.pod | |
parent | 88c28b3819570e2ea7914875b25f0f40654c570d (diff) | |
download | perl-db6b975f9cb8d5cea11d22f5f915e92c22c51889.tar.gz |
perlop - Use a tied scalar directly in chained comparison examples
Diffstat (limited to 'pod/perlop.pod')
-rw-r--r-- | pod/perlop.pod | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod index 08466e1219..2f0fa4abf7 100644 --- a/pod/perlop.pod +++ b/pod/perlop.pod @@ -99,18 +99,19 @@ a tied scalar, then the expression is evaluated to produce that scalar at most once, but the value of that scalar may be fetched up to twice, once for each comparison in which it is actually used. -In this example, the subroutine is called only once, and the tied -scalar it returns is fetched for each comparison that uses it. +In this example, the expression is evaluated only once, and the tied +scalar (the result of the expression) is fetched for each comparison that +uses it. - if ($x < get_tied_scalar() < $z) { ... + if ($x < $tied_scalar < $z) { ... -In the next example, the subroutine is called only once, and the tied -scalar it returns is fetched once as part of the operation within the -expression. The result of that operation is fetched for each comparison, -which normally doesn't matter unless that expression result is also -magical due to operator overloading. +In the next example, the expression is evaluated only once, and the tied +scalar is fetched once as part of the operation within the expression. +The result of that operation is fetched for each comparison, which +normally doesn't matter unless that expression result is also magical due +to operator overloading. - if ($x < get_tied_scalar() + 42 < $z) { ... + if ($x < $tied_scalar + 42 < $z) { ... Some operators are instead non-associative, meaning that it is a syntax error to use a sequence of those operators of the same precedence. |