Re: How to suss out module dependencies...

[email protected] ("C. Chad Wallace")
Newsgroups perl.dbi.users
Organization The Lodging Company
Message-ID <[email protected]>
At 6:09 PM on 27 May 2010, William Bulley wrote:

> According to Hendrik Schumacher <[email protected]> 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
"require"d instead of "use"d--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 (application/pgp-signature, 197 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkv+9SQACgkQKeSNHCYiCKDYeQCeJSfUXuZZ5BcbBl2PL6FGH/+1
3YQAoLYCigoEUyqYNSpHVPnAVEJLIz5p
=rhcj
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.