Tweet

How do I tell what version of a module is installed?

CPAN

If you have cpan installed (type cpan in your command prompt), then you can use:

    i ModuleName

For example:

    i CGI

will produce something like the following output:

    CPAN: Storable loaded ok (v2.18)
    Going to read '/root/.cpan/Metadata'
      Database was generated on Mon, 09 Jul 2012 05:27:04 GMT
    CPAN: YAML loaded ok (v0.72)
    Going to read 82 yaml files from /root/.cpan/build/
    CPAN: Time::HiRes loaded ok (v1.9711)
    DONE
    Restored the state of none (in 1.2623 secs)
    Module id = CGI
        DESCRIPTION  Simple Common Gateway Interface Class
        CPAN_USERID  LDS (Lincoln D. Stein )
        CPAN_VERSION 3.59
        CPAN_FILE    M/MA/MARKSTOS/CGI.pm-3.59.tar.gz
        DSLIP_STATUS RdpOp (released,developer,perl,object-oriented,Standard-Perl)
        MANPAGE      CGI - Simple Common Gateway Interface Class
        INST_FILE    /usr/share/perl/5.10/CGI.pm
        INST_VERSION 3.29

CPANPLUS

If you have cpanplus installed, (type cpanp), then you can use:

    l ModuleName

For example:

    l CGI

will produce something like the following, (some output omitted for clarity):

    Details for 'CGI'
    Author                   Mark Stosberg (mark@summersault.com)
    Description              Simple Common Gateway Interface Class
    Development Stage        Released
    Installed File           /usr/local/perl_dev/lib/5.10.1/CGI.pm
    Interface Style          Object oriented using blessed references and/or inheritance
    Language Used            Perl-only, no compiler needed, should be platform independent
    Package                  CGI.pm-3.59.tar.gz
    Public License           Standard-Perl: user may choose between GPL and Artistic
    Version Installed        3.43
    Version on CPAN          3.59
    Contains:                CGI                                           3.59     
                             CGI::Apache                                   1.01     
                             CGI::Carp                                     3.51     

The cpanplus shell is particularly powerful and it's many command line options are well worth the effort to master.

Command Line

If the author of a module has implemented a VERSION variable, (most do), you can use Perl from the command line to determine the module version.

    perl -M[modulename] -e 'print "$[modulename]::VERSION\n";'

For example:

    perl -MCGI -e 'print "$CGI::VERSION\n";'

This would produce something like:

    3.29

ActiveState (Windows)

Like solution 2, you can use perl from the command line to determine the module version, only the quotes are slightly different:

    perl -M[modulename] -e "print \"$[modulename]::VERSION\";"

For example:

    perl -MCGI -e "print \"$CGI::VERSION\";"

ppm (Windows)

From your command line you can type 'ppm'. If you type in:

    query

ppm will display information about the modules installed. This does not include standard perl modules, so, for example,

    query CGI

will not return any data. However:

    query DBI

will return something like:

    DBI [1.14] Database independent interface for Perl

See also

Revision: 1.1 [Top]