Interesting Perl 5 modules

In my journey into Perl this last year or so I’ve naturally done a lot of research on available modules. After all, the huge variety of CPAN is one of Perl’s strongest points. I journaled a few modules that struck me as particularly interesting, so why not merge these notes and links and publish them for others finding their way in the modern Perl world.

PSGI/Plack

Superglue interface between perl web application frameworks and web servers, just like Perl is the duct tape of the internet.

Inspired by Python’s WSGI and Ruby’s Rack, this is the modern way of doing Perl web apps.

PSGI is a specification to decouple web server environments from web application framework code. […] Web application developers (end users) are not supposed to run their web applications directly using the PSGI interface, but instead are encouraged to use frameworks that support PSGI, or use the helper implementations like Plack (more on that later).

A large number of HTTP servers support PSGI, so you’ll find anything from simple embedded solutions to non-blocking, asynchronous ones with Comet support.

Similarly, a large number of web frameworks have been built with support for the PSGI spec, again from the advanced and complex like Catalyst to the simple like Dancer. At first I wanted to show off some cool Perl web frameworks in this post, but there are so many nowadays that would deserve to be mentioned that I’ll just refer you to the PSGI/Plack site and let you pick whatever floats your boat.

AnyEvent

the DBI of event loop programming

AnyEvent lets you write event-based (callback-based) code without limiting you to a certain event loop. The event loop based nature of your module is transparent to the user. A large number of external loops are supported, among them Glib (for GTK/Gnome apps) and Qt.

There’s also POE with a very similar purpose. This post and its comments contain a lot of useful information and opinions to compare the two.

Dist::Zilla

distribution builder; installer not included!

Similar to many other modules, this one helps build distributions for upload to CPAN. However, it does not address installation of the module. Therefore, it can do powerful stuff, as it’s only run by developers and typically runs on a repository. It features a promising git integration module, for instance. Reviews are very favorable.

Data::Traverse

Callback-based depth-first traversal of Perl data structures

Data::Traverse exports a single function, traverse, which takes a BLOCK and a reference to a data structure containing arrays or hashes. […] Data::Traverse performs a depth-first traversal of the structure and calls the code in the BLOCK for each scalar it finds.

Simple and useful.

Email::Stuff

A more casual approach to creating and sending Email:: emails

In a “Why use this?” section – a good idea – the author shows that using this module, you don’t need to know how to structure MIME messages, and the code is very short and clear.


Email::Stuff->to('Simon Cozens<simon@somewhere.jp>')
            ->from('Santa@northpole.org')
            ->text_body("You've been a good boy this year.")
            ->attach_file('choochoo.gif')
            ->send;
Advertisements

Tags: , , , ,


%d bloggers like this: