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

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

  (email not shown publicly)
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Monday October 29, 2007
12:18 PM

Just what the (code) doctor ordered

[ #34781 ]

After noticing a bunch of duplicated code, I realized that a particular value which needed to be munged only if it was set could be refactored as follows:

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

I always forget about that construct, but when you need it, it's great!

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.
  • That is so cool and useful, why have I not seen it before? I must re-read my Perl books, I must have missed tonnes of stuff like that.

    -- "It's not magic, it's work..."
    • In 5.10, I don't think there's going to be a corresponding feature for this:

      $value //= $default;

      You still have to write:

      $value = $cgi->p($value) if defined $value;
      • This is one of the Perl 6 ideas that everyone wants back-porting I think.

        I see that &&= is explained on page 92 of my Programming Perl 2nd edition. Not coming from a c background I missed the utility of some of these.

        -- "It's not magic, it's work..."