Click here to get back home

Listing all modules used by program?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Listing all modules used by program? Pat Deegan 02-18-2006
Posted by Pat Deegan on February 18, 2006, 7:46 pm
Please log in for more thread options


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


Posted by harryfmudd [AT] comcast [DOT] on February 18, 2006, 11:01 pm
Please log in for more thread options


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

Posted by Pat Deegan on February 20, 2006, 3:07 pm
Please log in for more thread options


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


Posted by nobull@mail.com on February 25, 2006, 5:47 am
Please log in for more thread options


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.


Posted by Andy Hassall on February 19, 2006, 7:22 am
Please log in for more thread options


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

>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/Module/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

Similar ThreadsPosted
Social Marketing Tip that Kills Google...... takes less than 24 hours for #1 Listing no B.S February 8, 2008, 4:20 am
Please help me on the following perl program November 21, 2005, 8:41 pm
ANN: Apache-Authen-Program 0.93 September 22, 2004, 2:37 am
New Affiliate program 80% Commission April 14, 2005, 1:25 pm
Error in Inline C program July 19, 2005, 2:55 am
Program errors after module updates October 21, 2004, 9:15 am
How to invoke a CGI script within a Perl program ? May 6, 2005, 12:35 pm
Starting a perl program when I connect to the internet. September 22, 2004, 3:34 pm
Error in Perl Inline::C program running November 3, 2005, 4:00 am
finding the most relevant keywords or phrases of a content using a perl program September 21, 2005, 7:10 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap