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

Fellow Monasterians,

Is there a way to find out what version of a module my script is running if there are more than two versions installed?

My web host has an ancient version of DBD::mysql, so I THINK I successfully installed the latest version in my private directory, but I'm sure. How can I tell which one is running? And is there a way to force it to use the one I installed an not the web hosts'?

#!/usr/local/bin/perl -w print "Content-type: text/plain\n\n"; use lib "/usr/home/username/mylib/"; use strict; use Data::Dumper; use DBD::mysql; use ExtUtils::Installed; my $inst = ExtUtils::Installed->new(); my @modules = $inst->modules(); print Dumper(@modules); my $version = $inst->version('DBD::mysql'); print Dumper ($version);

...turned up nothing really. Thanks!


—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Replies are listed 'Best First'.
Re: Finding version of a particular CPAN module
by jZed (Prior) on Dec 07, 2005 at 02:58 UTC
    In a script "$DBD::mysql::VERSION" will work. On the command line, With DBI related modules, there's a little trick which I (pshaw, false modesty, blah, blah) originally wrote. To use it do this (notice, no print statement):
    perl -MDBI -e "DBI->installed_versions"
    
    That will tell you the versions of perl, DBI, and all the DBDs you have.

      Thanks jZed? I ran this instead (needed it within a Perl script):

      use lib "/usr/home/username/modules/"; use DBD::mysql; print $DBD::mysql::VERSION;

      I tshowed up the one I installed, and not the host's older one. However, when I remarked out the use lib line, it found the host's version. So, now I've answered some of my own OP.


      —Brad
      "The important work of moving the world forward does not wait to be done by perfect men." George Eliot
Re: Finding version of a particular CPAN module
by jacques (Priest) on Dec 08, 2005 at 00:15 UTC
    If you use my module HTML::Perlinfo, you can see the version number for each module in an HTML page. Just do:
    use HTML::Perlinfo; perlinfo(INFO_MODULES);