Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-10-23 11:01 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (279 votes). Check out past polls.