<intro>
I know that Duff's device in perl has already been discussed here and most probably elsewhere. In particular a Super Search turned out the following threads:

Basically they all discuss the perl version/translation of the actual Duff's device logic. But I'm asking something different.
</intro>

Specifically I'm asking about highly bummed perl code, that one has felt the need to write instead of a less obscure version. Indeed there would be tons of obfu and golf code to exhibit - but I'm not talking about stuff done for fun. I'm rather focusing on so called "production code" in which one has felt for whatever reson the need to leave obscure code spotting an intricate and maybe surprising perl feature, probably along with a big comment indicating both what he/she is doing and why he is doing it that way.

So, do you have a favourite code portion of yours that you would regard as your own perlsonal equivalent of Duff's device?

Note: in case you wonder and before you point it out... since this has directly or indirectly to do with some sort of optimisation: yes, I know that "premature optimisation is the root of all evil", and I'm asking just out of curiosity!

Update: to partially answer to myself, I was thinking about something along the lines of this example of mine, and check in particular merlyn's comment, which IMHO makes it appropriate for this discussion. But I bet there must be something more akin to the abstract essence of "Duff's device"...


In reply to Perl's own Duff's device? by blazar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.