This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Perl CPAN module help


Brian Dessent wrote:


How do you list modules already installed?


There's no definitive way to do this.  If you just want to see if you
have the Foo::Bar module, you can use "perl -MFoo::Bar -e 1" and if you
get an error then you need to install Foo::Bar.

You can also try the following script which uses the ExtUtils::Installed
module, but I have found that its output is sometimes misleading, in
that it will not display base (stock included) modules.  And I'm not
sure if it knows about modules that are installed through means other
than CPAN (e.g. through your distro's package manager.)

I've been doing something similar. Really it's been so long now, I forget it's origins or much of anything about the why or how of it other than it's a comprehensive listing that lets me know what I have & the status of the versions.

#!/usr/bin/perl

use CPAN;
# list all modules on my disk and note the newer versions
for $mod (CPAN::Shell->expand("Module","/./")){
        next unless $mod->inst_file;
                # here only when installed
        if ($mod->inst_version eq "undef") {
                printf "%s :No VERSION\n", $mod->id;
        }
        elsif ($mod->uptodate){
                printf "%s %s\n", $mod->id, $mod->inst_version
        }
        else {
                # here when not up to date
        printf "%s %s, NEW VERSION=%s\n",
                $mod->id, $mod->inst_version, $mod->cpan_version;
        }
}

Doug VanLeuven


-- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]