What kind of syntactic sugar is available in Perl to reduce code for l/rvalue operators vs. if statements?
问题 There's a bunch out there, as Perl is a pretty sugary language, but the most used statements in any language is the combination of if statements and setting values. I think I've found many of them, but there's still a few gaps. Ultimately, the goal would be to not have to write a variable name more than once: Here's what I have so far: $r ||= $s; # $r = $s unless ($r); $r //= $s; # $r = $s unless (defined $r); $r &&= $s; # $r = $s if ($r); $r = $c ? $s : $t; # if ($c) { $r = $s } else { $r =