in reply to w/Modules and w/o Modules
…please explain to me when using a module is most beneficial?When it’s beneficial. :)
A lot of my work with Perl revolves around web applications. My list of beneficial modules is almost always along the lines of
- CGI::Simple (CGI.pm without the HTML construction)
- CGI::Application plus assorted plugins
- the mighty DBI as already mentioned
- Date::Format and Date::Parse
One module I’d like to draw attention to is the marvellous Data::Page “help when paging through sets of results”. And that is exactly what it does, no more, no less. The author includes a note in the docs
It has been said before that this code is "too simple" for CPAN, but I must disagree. I have seen people write this kind of code over and over again and they always get it wrong. Perhaps now they will spend more time getting the rest of their code right...“…always get it wrong.” Done that! :) I’ve never had so many off by one errors in so few lines of code. It even gives you the numbers for your MySQL limit clause. This for me is an excellent example of a beneficial module.
I’m not a fan of all modules. Although frequently recommended by senior monks I have never gotten on with File::Find and its relatives. My use case is almost always “give me a list of all files under this dir”. I’ll grep for what files I want myself. So I’ve hand rolled a sub that does just that and everything got better, no more battling with, imo, quite difficult docs. I’m not advocating anyone else adopt this approach.
I find modules extremely beneficial. There are times when I find them a nuisance and avoid them but that is very rare indeed.