MacPorts is a valuable source of Open Source packages for OS X (that I've mentioned before). It's mostly kept pretty up to date which helps with installing current versions of software easily, including the dependencies.

MacPorts also includes some Perl modules (but by no means all of CPAN -- the Comprehensive Perl Archive Network). Where possible I prefer to install language modules using the "Operating System" packaging since it means that a single set of tools can be used to manage, version, and upgrade the packages without much additional thought. (Perl has its own set of CPAN install tools which will attempt to do some of its own package management, but once you start down that path you have N instances of package management for each product and rapidly ends up as messy as just randomly installing things without any packaging. See also Microsoft Windows "packaging".)

Unfortunately some of the Perl modules in MacPorts are not kept up to date. I ran into this yesterday with Text::CSV_XS, a Perl module to parse CSV files. The latest version in CPAN is 0.71, but the current version in MacPorts is 0.34, which is two years out of date -- and unfortunately misses certain features that I needed to handle broken CSV files. (In particular Freeswitch appears to generate invalid CSV files that do not properly escape double quotes (") in text fields, so various hacks are required to endeavour to parse them as CSV anyway. The relevant workaround seems to have been introduced in Text::CSV_XS in version 0.43.) There's been an open MacPorts Trac ticket (#15576) for most of the two years asking for the port to be updated to build the new version, complete with patches, but to date it still hasn't been applied.

Fortunately most Perl modules require very little change in package installation from version to version, since they tend to have the same files that need to be installed in each version. So updating to a new version can be done by changing the Portfile (in /opt/local/var/macports/sources/rsync/release/ports named after the port name, eg perl/p5-text-csv_xs) to reflect the new version and archive checksums. Viz:

--- Portfile.0.34   2008-03-13 18:27:50.000000000 +1300
+++ Portfile    2010-02-25 14:14:03.000000000 +1300
@@ -3,7 +3,7 @@
 PortSystem      1.0
 PortGroup       perl5 1.0
 
-perl5.setup     Text-CSV_XS 0.34
+perl5.setup     Text-CSV_XS 0.71
 platforms       darwin
 maintainers     oaf.dk:mni
 description     Perl module containing comma-separated values manipulation routines
@@ -14,6 +14,6 @@
     fields into a CSV string and parse a CSV string into fields.
 
 extract.suffix  .tgz
-checksums       md5 9e10d0ccf0aa1111098eca12d0de87a3 \
-                sha1 179436e8bf428e9a891b5cb079cb4c3f4a74d409 \
-                rmd160 36cacf941299da68f64261550a0a2e0dcd9ca434
+checksums       md5 a1201befb73819e7b7bb3adf78b08b95 \
+                sha1 c37891a84cb179036f40a92676a99d31b50bdc26 \
+                rmd160 470004cfdf6ee398eba24e9a2a966fb0ce9e3c3a

It needs three checksums, which can be calculated on Mac OS X with:

md5 FILE
shasum FILE
openssl rmd160 FILE

having downloaded the relevant archive file and checked its correct.

Having patched the Portfile, its sufficient to do:

port upgrade p5-text-csv_xs

and it will be rebuilt and the new version installed.

Unfortunately the changes to the Portfile will be overwritten by the next port selfupdate (since that uses rsync to bring the file to be identical to the master version), so it needs to be repatched each time you want to update the port. (It'd be useful if Macports used a distributed revision control system, eg git, that allowed for quick updates and local changes.) But it's sufficient to get a new enough version installed for me to be able to do my work. (And perhaps eventually MacPorts might apply the patch....)