09.04.08

How To Determine Perl Module Versions

Posted in Intermediate, Linux at 12:55 pm by Techie

How do you determine what version of a Perl module you have? If you have one module you want to check, you can call the VERSION parameter of the module. Let’s say you wanted to check the version of Test::Harness you had on your system. Run the following:

$ perl -MTest::Harness -le 'print Test::Harness->VERSION'
2.56
$

Another way:

$ perl -le 'eval "require $ARGV[0]" and print $ARGV[0]->VERSION' Test::Harness
2.56
$

Seems simple enough. But what if we want to check all module versions, versus what was current on CPAN?

$ perl -MCPAN -e 'CPAN::Shell->r'

That’s not foolproof, as some modules don’t have version numbers, but should give you a good idea. It also has the bonus of providing you with information on how out of date you are with CPAN.

Leave a Comment

Bad Behavior has blocked 280 access attempts in the last 7 days.