how to list all loaded modules of a perl program

Discussion in 'Perl Misc' started by Fei Liu, Mar 27, 2007.

  1. Fei Liu

    Fei Liu Guest

    Hi group, is it possible to list all loaded modules of a perl program?
    For example, the perl application could have a very complicated
    hierarchy of module structure where each module load different modules
    on their own:

    i.e
    package main
    use A;
    use C;

    package A
    use B;

    package C
    use D;

    package B
    use BA;
    use BB;

    package D;
    use DA;
    use DB;
    use DC;

    package DA
    use DAA;
    use DAB;

    etc, etc.

    Now is it possible within the main program to list all the preloaded
    modules via use statement? It's possible to do this by using a parser
    to recursively parse through modules with a predefined level, but
    idealy a in program complete list could be better.

    Please let me know if there is an existing solution for this problem,
    thanks!

    Fei
     
    Fei Liu, Mar 27, 2007
    #1
    1. Advertisements

  2. %INC

    hp
     
    Peter J. Holzer, Mar 27, 2007
    #2
    1. Advertisements

  3. Fei Liu

    usenet Guest

    At any time in a program you may print the contents of %INC, which
    will tell you what modules are loaded.

    If you want to know every module ever loaded, use an end block, such
    as:

    END {
    print Dumper \%INC;
    }


    If you wish to know how much time your program spent inside of each
    method of each module:

    perl -d:profile whatever.pl
     
    usenet, Mar 27, 2007
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.