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:

    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,

    Fei Liu, Mar 27, 2007
    1. Advertisements

  2. %INC

    Peter J. Holzer, Mar 27, 2007
    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

    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
    usenet, Mar 27, 2007
    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.