Listing all modules used by program?

Listing all modules used by program?

am 19.02.2006 01:46:56 von Pat Deegan

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.

--
Pat Deegan,
http://www.psychogenic.com/
Registered Linux User #128131

Re: Listing all modules used by program?

am 19.02.2006 05:01:07 von unknown

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

Re: Listing all modules used by program?

am 19.02.2006 13:22:05 von Andy Hassall

On Sat, 18 Feb 2006 19:46:56 -0500, Pat Deegan
wrote:

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

http://search.cpan.org/~smueller/Module-ScanDeps-0.55/lib/Mo dule/ScanDeps.pm

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Re: Listing all modules used by program?

am 19.02.2006 19:19:05 von John Bokma

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.

You might want to have a look at PAR. Note that modules that are use'd in
a special way might still be overlooked (e.g. on run time using require in
an eval)

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
I ploink googlegroups.com :-)

Re: Listing all modules used by program?

am 20.02.2006 21:07:10 von Pat Deegan

Hi,

On Sat, 18 Feb 2006 23:01:07 -0500, harryfmudd [AT] comcast [DOT] net
wrote:
> Pat Deegan wrote:
>> Greetings all,
>>
>> I'm trying to figure out how to automatically list all the modules used by
>> a particular program.

> If by "used" you mean as in the Perl built-in "use", will this do it for
> you?
>
> foreach (sort keys %INC) {print "$_\n"}

Ah. Well I was originally looking for something to executed without
modifying the program (such as a command line arg passed to perl itself)
but this is a minor mod and it works quite well. The only downside
is that it lists everything, including the core modules.

As with everything perl, seems there are other ways of doing this...
Module::ScanDeps, as suggested by Andy elsewhere in this thread, provides
a scandeps.pl helper which also works well with:

scandeps.pl -x ./myscript.pl

while only listing the core modules when explicitly requested (using the
-B argument to scandeps).

Thanks to all,
--
Pat Deegan,
http://www.psychogenic.com/
Registered Linux User #128131

Re: Listing all modules used by program?

am 25.02.2006 11:47:37 von nobull67

Pat Deegan wrote:
> Hi,
>
> On Sat, 18 Feb 2006 23:01:07 -0500, harryfmudd [AT] comcast [DOT] net
> wrote:
> > Pat Deegan wrote:
> >> Greetings all,
> >>
> >> I'm trying to figure out how to automatically list all the modules used by
> >> a particular program.
>
> > If by "used" you mean as in the Perl built-in "use", will this do it for
> > you?
> >
> > foreach (sort keys %INC) {print "$_\n"}
>
> Ah. Well I was originally looking for something to executed without
> modifying the program (such as a command line arg passed to perl itself)
> but this is a minor mod and it works quite well.

You can place the command in an END{} block in another module then load
the latter with the -M command line switch.