Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Programatically getting list of dependecies of a CPAN module?

by Plankton (Priest)
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 = "http://search.cpan.org/CPAN/authors/id/" . $mod->{ +'RO'}{'CPAN_FILE'} . "\n"; print "$url"; }
... so if I do ...
$ ./myscript.pl LWP
... I get ...
http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/libwww-perl-5.836.tar +.gz
... but I would like to also get a list of dependencies also.

Comment on Programatically getting list of dependecies of a CPAN module?
Select or Download Code
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?
Username:
Password:

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
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (11)
As of 2014-09-19 16:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (143 votes), past polls