Re: How to suss out module dependencies...

2010-05-27 Thread C. Chad Wallace

At 2:53 PM on 27 May 2010, William Bulley wrote:

 I have a Perl application that uses many Perl modules.  Most come from
 CPAN, some I have written, others come with Perl distributions
 (core?).
 
 I am faced with the need to transport this collection of Perl code
 from operating system A to operating system B, both of which are
 perfectly well supported by Perl.  Over several months I have added
 to system A lots of modules that need other modules.
 
 Unfortunately, system B is rather devoid of most of the modules that I
 need for this application.  I dread having to make an inclusive list
 of all the modules and all the modules that those modules need, and
 so on, and so on.

The autobundle command of CPAN would give you a bundle file that lists
of all the modules you've installed on system A.  Then you can take
that bundle file over to system B and install it using CPAN.

Your bundle may end up with a lot of extra modules that your program
doesn't need, but you can edit the bundle file and remove them.

Or maybe you could see if you can get a profiler (like Devel::NYTProf)
to tell you which modules are loaded when you load and run your module.


-- 

C. Chad Wallace, B.Sc.
The Lodging Company
http://www.lodgingcompany.com/
OpenPGP Public Key ID: 0x262208A0



signature.asc
Description: PGP signature


Re: How to suss out module dependencies...

2010-05-27 Thread C. Chad Wallace

At 6:09 PM on 27 May 2010, William Bulley wrote:

 According to Hendrik Schumacher h...@activeframe.de on Thu, 05/27/10
 at 17:05:
  
  A crude solution would be to print the contents of %INC somewhere
  in your application:
  
  perl -e 'use DBI; use Time::Local; print join (\n, keys %INC);'
 
 Good suggestion, but won't that list a whole bunch of other stuff
 that is not being used, but that exists in the INC tree somewhere?

Actually, no.  %INC only lists modules that have been loaded into the
current instance, via the 'do', 'require', or 'use' operators.[1]  

The only extraneous stuff it includes is the pragmas (strict, features,
warnings, etc.) but those are easily excluded because of their
all-lowercase names.

Now that Hendrik mentioned it, it seems to me that %INC is probably your
best bet.  But what you would have to be sure of, in the script that
loads your module to dump %INC, is that you also run your module through
its paces to be sure that all dependencies are loaded--even if some are
required instead of used--before you dump %INC.


[1] see the %INC entry in perlvar.

-- 

C. Chad Wallace, B.Sc.
The Lodging Company
http://www.lodgingcompany.com/
OpenPGP Public Key ID: 0x262208A0



signature.asc
Description: PGP signature