Printing individual perl module versions

Last week I discussed how to use the Perl debugger to print the module versions that a program references. While reading through the perlmod documentation, I saw Perl’s “-M” option. This allows a module to be specified on the command line (versus referencing it with a “use’ statement). Each Perl module should export the $VERSION variable, so finding the version number of a specific module is a snap:

$ perl -MNet::LDAP -e ‘print “$Net::LDAP::VERSION\n”‘
0.32

This will print the module version for the Net::LDAP module, as listed in the Net::LDAP perl module (pm) file:

$ pwd
/usr/local/lib/perl5/site_perl/5.8.0/Net

$ grep \^\$VERSION LDAP.pm
$VERSION = “0.32″;

It is amazing how many nifty things are available in Perl!