8 CPAN modules I totally love
I spend a lot of my time in Perl land, you may not be surprised to find out. Over the years, there’s a bunch of odds and ends in the land of CPAN that I end up using a lot, that just make life that much easier. You know I’m all about an easy life, right? So, I thought I’d compile a short list of some of my favourites. In no particular order…
There comes a time in every perl developer’s life when he’s got something that wants a filehandle but he’s only got a string. Well, fortunately for every perl developer there’s’ IO::Stringy, gives up a filehandle that just appends to a string ref you give it. I use it very simply, but it has some layers of fanciness to it. I happened upon it when I needed to do some NET::FTP‘ing of dynamic content, I thought it was lame to have to write a temp file out, and voila, you don’t. Also convenient if you’ve got something writing to a filehandle and you just need to see what it’s doing for a run. Don’t use it every day, but I’m sure glad it’s there when I need to.
Now I love both autohanders and Damian Conway. Imagine the wonder of finding Sub::Installer! It’s a very elegant and clean way to build your on the fly subroutines and get them in the right package. So nice!
Here’s an easy and pretty powerful way to encapsulate your configuration files. The files are easy to read and easy to maintain. There’s a also Config::General which allows a lot more expressiveness in the config file, but I prefer the files to be easy and basic. It’s helps with maintenance and it helps me clarify things in my mind. Many times if my config files need to be super featureful, I find that there’s something amiss with the application.
Throw away your ROT13, if you’re going to encrypt something, may as well do it the NSA way. Rijndael is the AES standard and is fast and secure. This module easy to use, so I tend to use it anytime I need something protected. It may be overkill for many things, but the cost is minimal so I generally don’t see too much downside to it.
Sometimes, you just need something one way encrypted, as a unique identifier, as a one way password, etc. If you’re digesting, SHA’s the best one to use, even thought it seems that it may be compromised, this module let’s you easily use some of the heavier duty versions of SHA instead of just SHA1.
With all the encrypting and digesting you’re doing up there you might occasionally need to pass those results around on the internets. I like Base32 for doing this sometimes – the string does tend to get a little sizeable, but that’s no worry if you’re in a form. And it’s all websafe characters, so you don’t need to do any url encoding on it and you don’t have to worry if any of the characters have special meaning in a url or anywhere. Very convenient for many purposes.
Forget use constant with it’s crazy usage or defining subs that return something, Readonly is the easiest way to get that juicy constant action you’re looking for. It easily builds scalars, arrays, hashes or whatever you want and in a clearly identifiable way. Variables continue to work just like other variables, except that you can’t set them. Hott!
This is easily my templating module of choice. It’s a great framework that makes easy things easier and hard things are at worst just as hard. It doesn’t have much opinion on how you want to do things and gives you a huge variety of ways to organize and segregate your code and html. In my experience it’s a perfect mix of convenience and minimalism.