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 (Vicar)
on Jul 02, 2010 at 19:54 UTC ( [id://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.

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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-20 01:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found