Finding a Perl Module Version

How to find a perl module version

Simply type:

$ perl -MModule -e 'print "$Module::VERSION\n"'

For example, with Net::SSLeay:

$ perl -MNet::SSLeay -e 'print "$Net::SSLeay::VERSION\n"'
1.25

If you get an error like:

$ perl -MModule -e 'print "$Module::VERSION\n"'
Can't locate Module.pm in @INC (@INC contains: 
/System/Library/Perl/5.8.6/darwin-thread-multi-2level /System/Library/Perl/5.8.6
/Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 /Library/Perl
/Network/Library/Perl/5.8.6/darwin-thread-multi-2level
/Network/Library/Perl/5.8.6 /Network/Library/Perl
/System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level
/System/Library/Perl/Extras/5.8.6 /Library/Perl/5.8.1 .).
BEGIN failed--compilation aborted.

The module is not installed on your system

I (Jon Miner) wrote a handy shell script (perlmodver) to do this all for you. It accepts a Perl Module as an argument. If $PERL is defined, it is used instead of simply perl. Sample usage:

$ perlmodver Net::SSLeay
Net::SSLeay: 1.25
$ env PERL=/usr/bin/perl perlmodver Net::SSLeay
Net::SSLeay: 1.20

perlmodver source:

#!/bin/sh

mod=$1

if test "x$mod" = "x"; then
    echo "Usage: $0 <module>"
    exit
fi

if test "x$PERL" = "x"; then
    PERL=perl
fi

$PERL -M$mod -e "print \"$mod: \$$mod::VERSION\n\""




Keywords:perl module version   Doc ID:4222
Owner:MST Support .Group:Identity and Access Management
Created:2005-11-28 18:00 CSTUpdated:2022-05-25 14:15 CST
Sites:Identity and Access Management
Feedback:  0   0