Check Perl Module Versions

It will often arise that you are having a problem with a script that you know should be working. One way to troubleshoot why it’s not working is to compare versions.

There are many ways to check versions, some simpler than others. Here are a few that we use:

Check Perl Module Version with CPAN

This seems to give great info about the author, and if the module is installed or not. It fails gracefully in the case that the module is not installed:

Check Perl Module Version with V

The V module is a module that you’ll need to install (it came with strawberry Perl though), but once you do, it nicely tells you about other installed modules:

Check Module from Linux CLI

If the module is compiled, and has the VERSION info in it, then you can ask the module directly with a Perl one liner:

Check Module form Windows CLI

The same caveats for windows, but we need to use double quotes instead of single quotes to avoid the error Can’t find string terminator “‘” anywhere before EOF at -e line 1.

Check One Module Using Perl

This is a clean version that is easier than the one liner above, especially if you can’t remember what to type and are checking many versions periodically:

dbi

Check All Out of Date Modules using CPAN -O

I like this way because it’s easy, it’s built in, and I can grep through what I need. (a combination of awk and simple logic could tell me all out of date only modules if desired):

cpan -O

Check Modules the Scripted Way

This will list all modules installed and their current version. It’s like cpan -O, but doesn’t tell you if they are out of date. This was floating around in a discussion on PerlMonks and is worth saving. It also uses the ExtUtils::Installed module, so it might not be allowed on your production system. However, it produces a nice TSV format for audit purposes:

perl-module-version

Conclusion

There are many ways to get the information you need to verify your modules. If you would like help with your Perl Project we can give you a free estimate. Just contact us!

Leave a Reply

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