Archive for the 'Perl' Category

Quick and Dirty Perl Hack: Is Foo::Bar Installed?

Monday, October 5th, 2009

Every so often, I need to find out whether I have a certain Perl module installed. Usually it’s either because of a security alert, or because I’m wondering how much of a pain it would be to install some package that has Some::Obscure::Module as a prerequisite.
I don’t know how y’all do it, what with the [...]

Don’t Put Information in Two Places

Sunday, April 5th, 2009

While playing around with a Perl script to look up stock quotes, I
kept getting warning messages about uninitialized values, as well as
mising data in the results.
I eventually tracked it down to a bug in an old version of the
Finance::Quote
Perl module, specifically to these lines:
# Yahoo uses encodes the desired fields as 1-2 character strings
# in [...]

I Get Email

Saturday, January 12th, 2008

Apparently, having my name in CPAN is a sign that I know everything about Perl, SOAP, XML, and security.
Unless someone can come up with a legitimate reason to send 5000 authentication requests to a web server (including an explanation of why that’s not a brain-damaged way to solve the problem at hand), I’m going to [...]

Pattern Substitution as Funky Iterator

Wednesday, October 3rd, 2007

I have a project in which I have a row of cells, and a number of segments of given lengths, and I need to try out all of the ways in which the segments can fit into the row. If you like, think of it as: how many ways can “eye”, “zygote”, and “is” be [...]

Removing Accents in Strings

Sunday, January 28th, 2007

I’ve been ripping and encoding a bunch of music. Since I’m a
hacker, naturally I have scripts that take a file with artist, album
title, and track titles, and finds the corresponding .wav or .aiff
source files, encodes them as MP3 and tags them.
A lot of the music I have is in French or German (and some Spanish
and [...]

How Do You Spell the Names of the Months?

Monday, December 11th, 2006

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 [...]

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

Thursday, March 16th, 2006

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.

Little Languages and Tables

Friday, January 27th, 2006

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 [...]