Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Installed Module Dependencies?

by pileofrogs (Priest)
on Jul 18, 2008 at 18:39 UTC ( #698698=perlquestion: print w/replies, xml ) Need Help??
pileofrogs has asked for the wisdom of the Perl Monks concerning the following question:

Is there a "good" way to find out what modules another module depends upon?

I want to build a machine with most of the perl libraries as another machine. I don't want to just use autobundle, because I don't want to install everything. I figure the best way to do this is to find all the modules aren't depended upon, IE the root of the dependency tree. In order to do that, I figure I'll have to go through all my installed modules and find out what they use/require and then take the results and turn them upside down. Once I have this list, it will be pretty easy to see what's junk and what's important.

I'd rather not parse the text of all the modules on my computer, so that's what I mean by "good", but if that's what I have to do, then so be it.


Replies are listed 'Best First'.
Re: Installed Module Dependencies?
by almut (Canon) on Jul 18, 2008 at 18:56 UTC

    Module::ScanDeps might help... (it's for example used by PAR)

    Update: but note that when you're dealing with XS modules, Module::ScanDeps won't determine secondary dependencies of shared object files (at least I wouldn't know how...).

    For example, lets say you're trying to track the dependencies of the module GD, which has architecture-specific parts. In this case, Module::ScanDeps will only tell you about the immediate shared object file that's loaded by Dynaloader.  However, in turn depends on a multitude of other shared libs, like libgd, libpng, libjpeg, libfreetype, libfontconfig, libexpat, etc., without which the shared object will not work...  (Some of those libs may come with the default OS installation, but typically not all of them... Also, you'd have to make sure that versions are matching.)

    In other words, if you want to get such a module working on another machine, you'd have to take care of determining/packaging those dependencies yourself (with the help of the appropriate system tool, like ldd on Linux).

Re: Installed Module Dependencies?
by oko1 (Deacon) on Jul 18, 2008 at 19:09 UTC

    Take a look at Module::ScanDeps. It comes with a script called '' that should do what you're looking for.

    (Disclaimer: I have not tested this thoroughly or used it in a live-fire scenario; I tracked it down by recalling that PAR/pp has this functionality, reading the docs, and trying a few simple tests.)

    Human history becomes more and more a race between education and catastrophe. -- HG Wells
Re: Installed Module Dependencies?
by Khen1950fx (Canon) on Jul 19, 2008 at 19:35 UTC
    Here's a little script that I use for finding dependencies:

    #!/usr/bin/perl use strict; use warnings; use ExtUtils::MakeMaker; use CPAN::FindDependencies; my $mod = prompt("Enter module name: "); my @dependencies = CPAN::FindDependencies::finddeps($mod); foreach my $dep (@dependencies) { print ' ' x $dep->depth(); print $dep->name().' ('.$dep->distribution().")\n" }

    It can be adjusted to fit your needs.

Re: Installed Module Dependencies?
by trwww (Priest) on Jul 19, 2008 at 01:02 UTC


    I didn't comb though your requirements, so this might be simple enough for you, but then again might not be.

    I've used the following when I need a list of modules that are loaded in to my application:

    perl -Ilib -MMyApp -e 'print map "$_\n", sort keys %INC'


Re: Installed Module Dependencies?
by DrHyde (Prior) on Jul 21, 2008 at 10:44 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://698698]
Approved by Corion
Front-paged by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2017-11-19 19:42 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (282 votes). Check out past polls.