Quick way of finding version number of a Perl module

Run this on command line

perl -MMyModule -le 'print "$MyModule::VERSION\n"'

For instance, to find out the version number of DBI installed on the machine, run

perl -MDBI -le 'print "$DBI::VERSION\n"'

To find out the version of DBD::mysql, run

perl -MDBD::mysql -le 'print "$DBD::mysql::VERSION\n"'

One caveat: this process does not seem to work on Windows, at least for my Strawberry Perl 5.10 installed on my Windows XP. I had to use the script below on Windows to get the version information. Here is the error message when I tried:

C:\junk>perl -MDBI -le ‘print “$DBI::VERSION\n”‘
Can’t find string terminator “‘” anywhere before EOF at -e line 1.

use DBI;
use DBD::mysql;

print "The version for DBI is $DBI::VERSION\n";
print "The version for DBD::mysql is $DBD::mysql::VERSION\n";

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.