perlmeditation
hacker
<p>How many times have you seen or heard a conversation like this?
<blockquote><i><foo> "I'm trying to use Module::Thing, and I'm running into trouble with the constructor. Can someone help?"</i>
<p><i><bar> "Have you tried using Other::Module instead? It has a more complete series of objects you can use, and it does the same thing as Module::Thing, but in less code."</i>
<p><i><blort> "What about using IO::Thing instead?"</i></blockquote>
<p>I've noticed this type of evolution many times over the last several years, where one (still useful) module has been deprecated by another module with similar or additional functionality. How do you know which module best fits the job, unless you can talk to people who walk around the halls of [http://cpan.org/|CPAN] on a daily basis and poke at module innards?
<p>Without the human interaction and experience provided by a site like [http://perlmonks.org|Perl Monks], this really wouldn't be as possible as it is with. IRC is a good medium for "real-time" exchange of information, but IRC doesn't have [Super Search]!
<p>I ran into this very recently with a script I wrote that used [LWP::UserAgent], [HTTP::Cookies], and [HTML::TableExtract] to log into [http://www.paypal.com|PayPal] and extract some payment statistics for me. The code worked, but was a bit longer and more convoluted than I would have liked. Enter [WWW::Mechanize], which allowed me to reduce the modules used from 5 to 3, and cut the amount of code down by 2/3, and add a bit of additional functionality, [id://249931|in less than 75 lines].
<p>If I hadn't talked to [bart] and [Corion] and some others who had used these kinds of modules before, I would still be rolling around with the stock LWP modules and doing hand-parsing of the content itself.
<p>Another example which just came up in [id://3184|the ChatterBox] was an example of validating a URI through the use of [Regexp::Common] and [Regexp::Common::URI::http]. I've been using the stock [URI] module to do this, splitting out the <i>scheme</i> and <i>authority</i> section, but now I see where [Regexp::Common] could be a better use of it. I would never have known about it unless [bart] or [broquaint] had mentioned it.
<p>Another one from yesterday was [Pod::Usage]. I never knew you could dump the pod from within a file itself, without having the user interactively run '<code>perldoc ./foo.pl</code>' on the code. Thanks to the experience and insight of [Enlil] and [tye], I've learned a "better way", and I shortened my code in the process.
<p>Yet another, [HTML::LinkExtor], which works well for extracting links from HTML pages, but can also be done (with much more robust functionality) using [HTML::TreeBuilder]. Granted, most of the modules I'm mentioning are HTML or "web" related, but that's the space I play in right now. I know this pardox exists across all of perl, however.
<p>What do other monks do when there is the possibility of a "better path to walk" with code and modules? <p>How do you know which module is "right" for the task? (or wrong for the task)<p>How do you search for something by name, which can only be described by concept?