How Do You Spell the Names of the Months?

One construct that I’ve seen (and used) a lot in Perl is a hash that maps month abbreviations to numeric values that can be fed to POSIX::strftime:

our %months = (
    "jan" => 0, "feb" => 1, "mar" => 3, ...
);

This is useful for parsing log files and such. It works, it’s quick and easy, and it doesn’t require a whole tree of dependent modules (which are always on the wrong side of the Internet) to be installed.

But what’s always bugged me is that this is the sort of thing that the machine ought to know already. And besides, it’s US-centric: what if the person running the script is in a non-English-speaking country?

Fortunately, I18N::Langinfo knows the names of the months. Read More

Pirate Mode Code

I don’t know whether anyone noticed, but on Talk Like A Pirate Day, all the text on this site was converted to pirate lingo.

This was done through
that I consed up for the occasion. Feel free to steal download and use it.

When to Optimize

The First Rule of Program Optimization:
Don’t do it.

The Second Rule of Program Optimization (for experts only!):
Don’t do it yet.

— Michael Jackson

Read More

How to Write A Good API

A lot has been written about how to design a good user interface, but very little about how to design a good programming interface (API: Application Program Interface, or a library). This is somewhat surprising, since an API is nothing more than an UI for programmers, and programmers are normally good at writing tools for each other.

Read More

Time-Related Things I Never Want to See In A Perl Script Again

I got stuck debugging someone else’s Perl code today, and it was chock-full of the sorts of things that annoy the piss out of those of us who know better.

Read More

Ajax == Emacs: the Next Generation

I’ve started learning this

thing. which allows you to do cool things like
Google Maps
and the
U Wisconsin directory search.

Read More

Little Languages and Tables

Recently, a coworker whipped up a Perl script that’ll build all of the
Perl modules we support. This is useful for when we add a new
supported OS or OS version. This script takes a config file, moduledefs, which lists the modules to build, as well as various quirks that affect how and whether the modules should be built. moduledefs is itself a `require‘d Perl script:

Read More