MacOS plist XML files are evil; even more so than regular XML. For instance, my iTunes library file consists mostly of entries like: <key>5436</key> <dict> <key>Track ID</key><integer>5436</integer> <key>Name</key><string>Getting Better</string> <key>Artist</key><string>The Beatles</string> <key>Composer</key><string>Paul McCartney/John Lennon</string> <key>Album</key><string>Sgt. Pepper’s Lonely Hearts Club Band</string> … </dict> You’ll notice that there’s no connection between a key and its value, other… Continue reading Evil Hack of the Day
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… Continue reading Quick and Dirty Perl Hack: Is Foo::Bar Installed?
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… Continue reading Don’t Put Information in Two Places
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… Continue reading I Get Email
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… Continue reading Pattern Substitution as Funky Iterator
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… Continue reading Removing Accents in Strings
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… Continue reading How Do You Spell the Names of the Months?
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.
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… Continue reading Little Languages and Tables