Re: Listing all modules used by program?



Pat Deegan wrote:
Greetings all,

I'm trying to figure out how to automatically list all the modules used by
a particular program.

The closest I've come is creating a CPAN autobundle but this includes
everything on the system, which isn't what I'm hoping for...

What I'd like is to create a .pm similar to CPANs snapshot autobundle but
which only includes the modules actually used by this program, thereby
allowing me to install all those (and only those) dependencies on a
different host with a minimum of manual labor.

The perltoc contains numerous "module" related entries but I didn't see
anything relevant. I thought it might be related to perlcc but the
manpage has no mention of such a function.

I'm certain I've managed this before -- anyone know how to accomplish this
feat?

Thanks in advance.


If by "used" you mean as in the Perl built-in "use", will this do it for you?

foreach (sort keys %INC) {print "$_\n"}

This needs to be inserted _after_ you are certain you have loaded all the modules you are going to load. To be safe, do it just before you exit.

Tom Wyant
.