|XP is just a number|
Looking for examples of well-written modulesby xdg (Monsignor)
|on Aug 26, 2004 at 21:34 UTC||Need Help??|
xdg has asked for the
wisdom of the Perl Monks concerning the following question:
Dear fellow perlmonks,
I'm looking for a list of well-written Perl modules.
I think of Perl as a very "literary" language. Between Larry Wall's focus on syntactic convenience and fluidity, the principles of TIMTOWTDI, and the plethora of idioms, Perl is written in a wide range of styles unique to individual authors. There is "Baby Perl" of course -- like the "See Spot Run" type books I had as a child. And it wouldn't be hard (and could be an interesting meditation) to make further literary analogies as well: code like Hemingway written in short choppy functions or code like Austen written in florid, overly commented and meandering code. (No offense to Austen fans intended.)
Just as I learned to write in English at least in part by doing a lot of reading, I feel my Perl writing would improve by more exposure to other people's code, particularly, to well-written code. I'm looking for pointers to particularly well written modules (or open-source perl projects) that demonstrate good technique across a range of styles.
In scouring PM and other places, I've not found much that addresses this directly. I'm not looking for a list of "great" modules. Typical answers to this kind of question can be seen on Learning from modules -- which suggests looking at favorite or popular or otherwise "great" modules. I love lists of cool modules like the Advent calendar, too. But cool or heavily used or popular modules are not necessarily well-written or good to learn from -- even though they may be quite functional for day-to-day usage. They may have some quick and dirty hacks inside, may be poorly documented, may be full of "cargo-cult" holdovers, or may be so idiomatic as to be nigh-impenetrable.
Just as I wouldn't point someone to Barnes and Noble and say, "go browse around some bestsellers" to someone looking for a well written book, being told to go look at popular modules on CPAN isn't particularly helpful and is something I could have figured out myself.
Perl code in books about Perl isn't bad but isn't too great either, as it tends to be written simply for a wide audience or tends to be idealized to demonstrate particular techniques or situations. (An exception is probably "Effective Perl Programming" which I'd analogize to Strunk & White "Elements of Style" for improving one's craft).
All of which is to say that I'm looking for thoughtful suggestions for well-written real-world code that is available for review. This could include (but shouldn't be limited to):
(To go one step further I'd also be interested in hearing the same about test-suites in modules. Now that I'm trying for a more TDD style, I'm pondering if I'm writing too many or too few tests in certain situations and good examples would be helpful.)
Thanks very much,
Code posted by xdg on PerlMonks is public domain. It has no warranties, express or implied. Posted code may not have been tested. Use at your own risk.
Edits: Fixed spellings for Austen and Hemingway -- thanks Cody Pendant. My degree was clearly not in English Lit. :-)