Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Checking for an installed Module's version.

by c (Hermit)
on Oct 03, 2002 at 16:36 UTC ( #202574=perlquestion: print w/replies, xml ) Need Help??

c has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing my first Makefile.pl that will put together another script based on the current system's environment. One of the things I'll be checking on is whether or not certain required modules are installed. I found this thread that shows how to find out if a module is present on a machine, however what about finding the version of the Module? I read through John's meditation but I'm not certain that it really provides the answer I'm looking for. It was the only return to a PM search on 'check module version'. Any known good methods of achieving this?

-c

  • Comment on Checking for an installed Module's version.

Replies are listed 'Best First'.
Re: Checking for an installed Module's version.
by jwest (Friar) on Oct 03, 2002 at 17:20 UTC
    If the module isa Exporter- or, at least, if it behaves like most CPAN modules I'm familiar with- you can usually find the version at the command line by:
    $ perl -MModule::Name -e 'print $Module::Name::VERSION,"\n"';

    Of course, if you're using ExtUtils::MakeMaker to write the make file, the WriteMakefile method has a parameter called 'PREREQ_PM' that lets you specify the modules you need as well as their minimum versions.

    Hope this helps!

    --jwest


    -><- -><- -><- -><- -><-
    All things are Perfect
        To every last Flaw
        And bound in accord
             With Eris's Law
     - HBT; The Book of Advice, 1:7
    
Re: Checking for an installed Module's version.
by chromatic (Archbishop) on Oct 03, 2002 at 18:29 UTC

    Module::Info does this rather well, but setting required modules and versions as prerequisites in the Makefile is probably a better idea.

(jeffa) Re: Checking for an installed Module's version.
by jeffa (Bishop) on Oct 03, 2002 at 18:31 UTC
Re: Checking for an installed Module's version.
by Anarion (Hermit) on Oct 03, 2002 at 16:42 UTC
    Try to load it and then check $@:
    perl -le 'eval "use CGI 2.81; ";print $@ if $@'
    $anarion=\$anarion;

    s==q^QBY_^=,$_^=$[x7,print

Re: Checking for an installed Module's version.
by Moonie (Friar) on Oct 03, 2002 at 16:55 UTC
    you may want to look at this link.
Re: Checking for an installed Module's version.
by perlm4drp (Initiate) on Mar 20, 2003 at 17:26 UTC
    Great guys, But how do I find all installed modules and their versions, without supplying module name on the command line? -Thanks, DP

      There are many ways, but this looks really nice and fancy: pmtools. In fact, I'm gonna try it out right now...

      non-Perl: Andy Ford

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://202574]
Approved by ybiC
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2020-01-20 21:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?