I don't think that "a compendium of elegant Perl idioms" will be a good description of the Perl Advanced Techniques Handbook. When people talk about 'idioms' they usually mean one- or two-line snippets like the one fastolfe mentioned that pre-extends a hash. But PATH isn't going to be about that at all.

The idea of PATH is that there are a lot of powerful programming techniques that are possible in Perl but not in other languages that Perl programmers are familiar with. Since Perl programmers haven't seen these techniques before, they don't know how to use them, what they are good for, or even that they exist, and they are letting a lot of the power and expressiveness of Perl go to waste. The techniques are not little things like pre-extending a hash. They are much bigger ideas that apply to the organization of entire programs, ideas on the scale of 'object-oriented programming'.

One example is the idea that in Perl you can write a function that manufactures other functions. Instead of writing a lot of similar functions in the source code, you instead write one function which, when called, generates the function that you actually want to use and returns it. By invoking this 'function factory' with different arguments, your program can manufacture as many functions as it needs to without your having to guess in advance what all the functions will need to do.

Perl's own sort operator is a limited example of this. If sort only sorted lists alphabetically, it would only bone ten-thousandth as useful as it is. But instead, it gets an argument, supplied by the programmer, which tells it how to compare two list elements. In effect, this extra argument transforms sort into a different function, which sorts lists in the way that the programmer specified; if you give it a different argument, you get a different kind of sorting function back out.

This is tremendously useful in the case of sort, but most Perl programmers don't realize that they can apply the same techniques to their own functions in many similar circumstances and make their own functions much more useful and general than they would have been otherwise.

Anyway, if you're interested, the correct URL is http://perl.plover.com/book/.


In reply to Re: Efficient Perl Programming by Dominus
in thread Efficient Perl Programming by Fastolfe

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.