Perl one liner to display module version info

I use this Perl one-liner to display the version number of a module. This module should be available in your @INC paths.

If I need to know the version of CGI.pm

$ perl -MCGI -e ‘print “$CGI::VERSION\n”‘
3.29

I created a shell script so that I can just type the module name.

$ cat pm_version.sh
#!/bin/sh
MODULE=$1
perl -M$MODULE -e ‘print “$’$MODULE’::VERSION\n”‘

So now, I can do this.

$ pm_version.sh Google::Adwords
v1.13

2 thoughts on “Perl one liner to display module version info

  1. Thanks for sharing the script. I would just like you to know that there is a more “standard” solution from this, within Perl, which additionally presents the advantage of being platform-independant. It is the Module::Info, installable from CPAN.

    http://search.cpan.org/search?query=Module::Info

    This module installs a script named module_info. Here is a demo, under Windows:

    “> c:>module_info Catalyst”
    ” ”
    “Name: Catalyst”
    “Version: 5.7014″
    “Directory: D:\perl\site\lib”
    “File: D:\perl\site\lib\Catalyst.pm”
    “Core module: no”

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>