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

Leave a Reply