Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Programatically getting list of dependecies of a CPAN module?

by Plankton (Vicar)
on Jul 02, 2010 at 19:54 UTC ( #847798=perlquestion: print w/replies, xml ) Need Help??
Plankton has asked for the wisdom of the Perl Monks concerning the following question:

Dear Wise Monks,

I am trying to write a script that will list the dependencies of a CPAN Perl module. I already have a script that will print out the tarball that contains the module ...

#!/usr/bin/perl -w use strict; use Data::Dumper; use CPAN; use File::Basename; for my $mod (CPAN::Shell->expand("Module", shift )) { my $url = "" . $mod->{ +'RO'}{'CPAN_FILE'} . "\n"; print "$url"; }
... so if I do ...
$ ./ LWP
... I get ... +.gz
... but I would like to also get a list of dependencies also.

Replies are listed 'Best First'.
Re: Programatically getting list of dependecies of a CPAN module?
by Khen1950fx (Canon) on Jul 02, 2010 at 21:14 UTC
    This'll work.
    #!/usr/bin/perl use strict; use warnings; use CPAN; use CPAN::FindDependencies; use File::Basename; my $mod = shift @ARGV; for $mod (CPAN::Shell->expand("Module", $mod )) { print $mod->cpan_file, "\n"; } my @dependencies = CPAN::FindDependencies::finddeps($mod,); foreach my $dep (@dependencies) { print ' ' x $dep->depth(); print $dep->name().' ('.$dep->distribution().")\n"; }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://847798]
Approved by AnomalousMonk
Front-paged by Old_Gray_Bear
and one hand claps...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2017-07-26 00:05 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (383 votes). Check out past polls.