artist has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
From my program, I like to find all the modules and the functions/subroutines/methods used from that modules. Compile time methods are fine, ie.. run time methods are not necessary. I like to find only those methods which are used in my programs and not all the available methods for the module. Looking for starting points. ====================================================
Stumbleupon

Replies are listed 'Best First'.
Re: Modules and Functions Listing
by davido (Cardinal) on Jan 08, 2004 at 05:23 UTC
    You may be looking at B::Xref.

    It works well from the command line as:

    perl -MO=Xref mytest.pl >mytest.xrf


    Dave

      I'd better take a look at that too - in Sub::WrapPackages I have a horrible hack which uses a function from Pod::Coverage to figure out what is defined where. A function which is documented as being subject to future change. Thanks!
Re: Modules and Functions Listing
by Roger (Parson) on Jan 08, 2004 at 05:25 UTC
    You might also want to checkout Devel::TraceLoad if you want to find out what modules are loaded.

    H:\Perl>perl -MDevel::TraceLoad p10.pl +strict.pm [from: p10.pl 1] +warnings.pm [from: p10.pl 2] +Data/Dumper.pm [from: p10.pl 3] +XSLoader.pm [from: C:/Perl/lib/Data/Dumper.pm 18] +Carp.pm [from: C:/Perl/lib/Data/Dumper.pm 21] +bytes.pm [from: C:/Perl/lib/Data/Dumper.pm 613] +Exporter.pm [from: C:/Perl/lib/Data/Dumper.pm 17] +overload.pm [from: C:/Perl/lib/Data/Dumper.pm 19] +warnings/register.pm [from: C:/Perl/lib/overload.pm 135]

    Update: I agree with davido that B::Xref is the way to go.

    janitored by ybiC: Fixed link to CPAN module - [cpan://Devel::Traceload]

Re: Modules and Functions Listing
by QwertyD (Pilgrim) on Jan 10, 2004 at 15:58 UTC

    A while ago, I was doing some refactoring where I needed a listing of all the subs and sub calls in a large program, which seems like almost what you want. I did a huge amount of searching through the Monestary. Here are some previous nodes that might be of help to you:

    Note that I haven't tried any of these extensively. Good luck!


    Once it's Turing complete, everything else is just syntactic sugar.