How do I find the module dependencies of my Perl script?

Posted by zoul on Stack Overflow See other posts from Stack Overflow or by zoul
Published on 2008-12-11T10:19:53Z Indexed on 2010/05/16 12:00 UTC
Read the original article Hit count: 353

Filed under:
|
|
|

I want another developer to run a Perl script I have written. The script uses many CPAN modules that have to be installed before the script can be run. Is it possible to make the script (or the perl binary) to dump a list of all the missing modules? Perl prints out the missing modules’ names when I attempt to run the script, but this is verbose and does not list all the missing modules at once. I’d like to do something like:

$ cpan -i `said-script --list-deps`

Or even:

$ list-deps said-script > required-modules # on my machine
$ cpan -i `cat required-modules` # on his machine

Is there a simple way to do it? This is not a show stopper, but I would like to make the other developer’s life easier. (The required modules are sprinkled across several files, so that it’s not easy for me to make the list by hand without missing anything. I know about PAR, but it seems a bit too complicated for what I want.)


Update: Thanks, Manni, that will do. I did not know about %INC, I only knew about @INC. I settled with something like this:

print join("\n", map { s|/|::|g; s|\.pm$||; $_ } keys %INC);

Which prints out:

Moose::Meta::TypeConstraint::Registry
Moose::Meta::Role::Application::ToClass
Class::C3
List::Util
Imager::Color
…

Looks like this will work.

© Stack Overflow or respective owner

Related posts about perl

Related posts about modules