Chas. Owens wrote:
> On Thu, Oct 16, 2008 at 00:06, howa <[EMAIL PROTECTED]> wrote:
>> Hello,
>>
>> Conside I have the code:
>>
>> use LWP::UserAgent ();
>> use Apache::DBI ();
>> use DBI ();
>> ...
>> ...
>>
>> Some points later, I want to list all the used modules, is it
>> possible?
>>
>> E.g. Print out
>>
>> LWP::UserAgent
>> Apache::DBI
>> DBI
>>
>>
>> Thanks.
> 
> You can use the global hash %INC* to find all files loaded via
> require, use, or do.
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> use Data::Dumper;
> 
> print "files loaded:\n", map { "\t$_\n" } sort keys %INC;
> 
> #make the files look like they would on a use
> print "modules loaded:\n", map { s#/#::#g; s/\.pm$//; "\t$_\n" } sort keys 
> %INC;
> 
> * http://perldoc.perl.org/perlvar.html#%INC

But remember that Perl can compile at run time, so the the list of loaded
modules can change continuously while a program is running.

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to