mstpan quick reference
by:
4 minutes
789 Words
2015-09-07 20:00 -0400
Last Christmas, the inimitable Matt Trout (mst) created an opinionated tour of CPAN where he recommended modules for some common problems. I think its brilliant, useful, and entertaining and I’ve decided to compile a high level overview all on one page in order to create a quick reference.
I’ve tried to distill his wisdom and wit down to a few words. But I recommend clicking the section headers and following the links to Matt’s original posts to see his actual real opinions in their full complexity. This single page can’t replace 16 great posts and he usually includes advice on the best way to use the module. You won’t want to miss that.
Table of Contents
- Web Frameworks
- Web Deployment
- XML
- HTML
- Files
- Databases
- JSON
- Async
- Library Deployment
- Perl VM Deployment
- Distribution building
- Object orientation
- SOAP
- Exporting
- Logging
Web Frameworks
- CGI.pm (the CPAN module) - Run away
- Catalyst - Venerable
- Dancer - Solid and lightweight
- Mojolicious - Shiny
- Web::Simple - Low level
- Plack - Awesome (but not a web framework)
Web Deployment
- mod_perl - Run away
- CGI (the protocol) - Ok for some trivial things
- FastCGI + unix sockets for zero downtime deploys - Yes
- Apache + FastCgiExternalServer - Good
- Nginx + Starman + Unix sockets - Good
- Mojolicious + Hypnotoad - Good
- PSGI Async
- Net::Async::HTTP::Server::PSGI if you like IO::Async
- Twiggy if you like AnyEvent
XML
- XML::Simple - No
- XML::Twig - Excellent whipuptitude
- XPath - Not a CPAN module but you should learn it
- XML::LibXML - Good
- Template::Semantic - Good
- XML::Toolkit - Good
- XML::Rabbit - Nice
- xmllint - Not a Perl module. But useful if you’re XML file is made of “old man wee and fail”
HTML
- Parsing HTML
- Regular expressions - Don’t
- HTML::TreeBuilder - Venerable
- Mojo::DOM - Pleasant
- XML::LibXML or XML::Twig - Ok but why
- Generating HTML
- CGI.pm - Please don’t
- Template Toolkit - Venerable
- Text::Xslate - Brilliant
- HTML::Mason - Yes but no because embedded Perl
- Mojo::Template - Yes but no because embedded Perl
- HTML::Zoom - mst wrote it, mst doesn’t hate it
Files
- Files::Spec - Core, standard
- Files::Spec::Functions - Use this instead of File::Spec
- File::stat - Yes
- autodie - Core, but “a giant bag of crack balanced precariously atop .. an even bigger bag of tainted crack”
- File::Open - Better than autodie
- File::Slurp - Avoid
- Path::Tiny - Excellent
- IO::All - Good if you want to be procedural and don’t want OO
Databases
- DBI - 99% of the time, just use these 2 methods and nothing else
$dbh->do($sql, {}, @args);
my @array_of_hashrefs = @{$dbh->selectall_arrayref($self, { Slice => {} }, @args)};
- DBIx::Connector - You want it
- Mojo::PG - Yes
- DBIx::Class - Yes
- DBIx::Class::Candy - Shiny
- DBIx::Class::DeploymentHandler - Yes
- DBIx::Class::Fixtures - Useful for testing
- DBIx::Class::PassphraseColum - Yes please
JSON
- JSON - Yes but there are alternatives
- JSON::PP - Pure perl, core, fatpacks
- JSON::XS - Fast
- Cpanel::JSON::XS - Faster
- JSON::MaybeXS - Recommended
- JSON::Diffable - Useful
- Mojo::JSON - Really nice
Async
- Don’t
- threads.pm - Don’t. Its slow.
- POE - Good but weird UI.
- MooseX::POE - Better
- Reflex - Interesting
- AnyEvent - Ok, but maintainer is difficult
- IO::Async - Nice
- Mojo::IOLoop - Nice
- Promises - Neat but mst likes Future
- curry - Useful
Library deployment
- cpan as root - No
- Vendor Packages - Ok
- CPANPLUS - Out of favor
- CPAN - Standard
- cpanminus - Use this
- FindBin - Good for git deploys, bad for dist deploys
- local::lib - Yes
- Carton - Yes
- App::FatPacker - Yes
- CPAN::Mini - Maximum underkill
- Pinto - Maximum overkill
Perl VM deployment
- System perl - Ok with local::lib
- Manual compilation - Yes
- perlbrew - Yes usually all the shims are more annoying than necessary
- Perl::Build - Nice
- plenv - Nice
- Windows - Active State or Strawberry Perl
Distribution building
- ExtUtils::MakeMaker - Hated by everyone except people who like Makefiles.
- Module::Build - No
- Module::Install - “a giant tower of crack”
- Module::Build::Tiny - Nice. See also App::ModuleBuildTiny.
- Dist::Zilla - Power. Maximum overkill.
- Dist::Milla - Sensible
- Minilla - Great. Maximum underkill.
Object orientation
- Moose - Awesome
- Moo - Shiny
- Mouse - Niche
- Type::Tiny - Yes
- Moops - Good
- Throwable - Sensible
- Safe::Isa - Might be useful
SOAP
- SOAP::WSDL - Avoid
- XML::Compile::SOAP - Insane and brilliant
- Catalyst::Controller::SOAP - Least worst option
- SOAP::Lite - Ancient and insane
Exporting
- Exporter - Sufficient
- Sub::Exporter - Worth a look
- Sub::Exporter::Progressive - Light
- Moose::Exporter - Yes
- Exporter::Tiny - Recommended
- Exporter::Declare - Maximum overkill
- namespace::(auto)clean - Useful
- Import::Into - or Import::Base
- Net::SMTP - Too low level
- Email::Send - Usable
- Email::Sender - Recommended
- Email::Stuffer - mst favorite
- Emailesque - mst favorite with sugar on top
- Email::Mime - Standard
- Email::Mime::Kit - Best answer for templating
- Mail::Box - Brilliant and insane
- Courriel - Elegant
Logging
- warn() - Perfectly fine
- Log::Dispatch - Nice
- Log::Log4Pperl - Maximum overkill
- Log::Any - Good
- Log::Contextual - Nice
- Message::Passing - Worth a look. Not quite logging.
Read other articles