Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • But that said, the operator that parallels &&= in this case can be defined by:

    $value = defined($value) ? $other_value : undef;

    but I'm not sure what it would be good for.
    • Reminds me of this:


      Use Alternate Value. If parameter is null or unset, nothing is substituted, otherwise the expansion of word is substituted.

      That’s from man bash [] under “Parameter Expansion”. It comes in handy when you want to decide whether to pass a switch to a program based on the presence of some flag variable.

    • It's useful if you want to munge a value if it's defined. I've found it useful when doing something like this:

      $message &&= $cgi->p($message);

      In other words, if there is no message, don't stick in extraneous paragraph tags in the HTML. I'm sure there are plenty of other cases where you might want to take an extra action if a value is defined.