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. Advertising

  2. On 2007-03-27 19:59, Fei Liu <> wrote:
    > Hi group, is it possible to list all loaded modules of a perl program?


    %INC

    hp

    --
    _ | Peter J. Holzer | Blaming Perl for the inability of programmers
    |_|_) | Sysadmin WSR | to write clearly is like blaming English for
    | | | | the circumlocutions of bureaucrats.
    __/ | http://www.hjp.at/ | -- Charlton Wilbur in clpm
     
    Peter J. Holzer, Mar 27, 2007
    #2
    1. Advertising

  3. Fei Liu

    Guest

    On Mar 27, 12:59 pm, "Fei Liu" <> wrote:
    > Hi group, is it possible to list all loaded modules of a perl program?


    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
     
    , Mar 27, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo Birnbach [MS]
    Replies:
    0
    Views:
    3,330
    Marcelo Birnbach [MS]
    Jun 28, 2003
  2. Udo Corban
    Replies:
    0
    Views:
    3,854
    Udo Corban
    Jan 23, 2004
  3. Jürgen Exner
    Replies:
    0
    Views:
    3,261
    Jürgen Exner
    Oct 13, 2009
  4. James E Keenan
    Replies:
    2
    Views:
    132
    James E Keenan
    Nov 15, 2005
  5. Fei Liu
    Replies:
    2
    Views:
    425
    -berlin.de
    Mar 28, 2007
Loading...

Share This Page