(back to projects)

Util::Underscore (Perl module)

This module is a collection of various helper functions. It solves two problems: (1) I like fully qualified subroutine names to avoid namespace pollution. (2) I don’t like having to remember which util module contains a given function. Util::Underscore therefore aliases them into the _ namespace so that they can be invoked like _::any { $_ > 0 } @nums. There are also a couple of new additions like _::croakf $pattern, @args as a shorthand for _::croak sprintf $pattern, @args, and various safe type checks like _::is_array_ref or _::can $object, $method.

I enjoy this module for personal projects and for one-liners, because it makes a large toolbox of functions immediately accessible. But for published projects, adding this large dependency is probably not the best idea :-)

The code for this module is not spectacular since it mostly consist of aliases. However, I expended significant effort to carefully document and test all functions. Where I just aliased the functions the tests only cover basic cases, but should be enough to prevent accidental breakage when an upstream module changes. The documentation is rather formal, and tends to surpass the original docs in quality. My experience writing these docs has lead to the blog post Good API documentation.