How to list all the nested modules

Discussion in 'Perl Misc' started by James, Jun 5, 2007.

  1. James

    James Guest

    How to list all the nested modules,
    similar to dependency in C-compiler (gcc -M)?

    For example,

    use Net::SSH::perl::packet;
    use Net::SSH::perl::Buffer;
    use Net::SSH::perl::Config;
    use Net::SSH::perl::Constants qw( :protocol :compat :hosts );
    use Net::SSH::perl::Cipher;
    use Net::SSH::perl::Util qw( :hosts _read_yes_or_no );
    use IO::Socket;
    use IO::Select;
    use Socket;
    use Fcntl;
    use Symbol;
    use Errno qw(EAGAIN EWOULDBLOCK);
    use Carp qw(croak);
    use Sys::Hostname;


    TIA
    James
    James, Jun 5, 2007
    #1
    1. Advertising

  2. James

    Paul Lalli Guest

    On Jun 5, 4:40 pm, James <> wrote:
    > How to list all the nested modules,
    > similar to dependency in C-compiler (gcc -M)?
    >
    > For example,
    >
    > use Net::SSH::perl::packet;
    > use Net::SSH::perl::Buffer;
    > use Net::SSH::perl::Config;
    > use Net::SSH::perl::Constants qw( :protocol :compat :hosts );
    > use Net::SSH::perl::Cipher;
    > use Net::SSH::perl::Util qw( :hosts _read_yes_or_no );
    > use IO::Socket;
    > use IO::Select;
    > use Socket;
    > use Fcntl;
    > use Symbol;
    > use Errno qw(EAGAIN EWOULDBLOCK);
    > use Carp qw(croak);
    > use Sys::Hostname;


    Not quite sure what you're going for, but maybe you want the keys of
    the %INC hash?

    $ perl -MLWP::Simple -le'
    for (sort keys %INC) {
    s!/!::!g;
    s!\.pm$!!;
    print;
    }
    '
    Carp
    Exporter
    Exporter::Heavy
    HTTP::Status
    LWP::Simple
    strict
    vars
    warnings
    warnings::register

    Paul Lalli
    Paul Lalli, Jun 5, 2007
    #2
    1. Advertising

  3. James

    Guest

    On Jun 5, 1:40 pm, James <> wrote:
    > How to list all the nested modules,


    At any time in a program you may print the contents of %INC, which
    will tell you what modules are loaded (you may prefer to print it
    using Dumper).

    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


    --
    The best way to get a good answer is to ask a good question.
    David Filmer (http://DavidFilmer.com)
    , Jun 5, 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. Benjamin Rutt

    getting list of all available modules

    Benjamin Rutt, Jun 21, 2005, in forum: Python
    Replies:
    2
    Views:
    368
    Peter Otten
    Jun 21, 2005
  2. John [H2O]
    Replies:
    0
    Views:
    281
    John [H2O]
    Oct 28, 2008
  3. harryos

    how to list all installed modules

    harryos, Feb 18, 2009, in forum: Python
    Replies:
    3
    Views:
    619
    harryos
    Feb 19, 2009
  4. Tim Michelsen

    creating a list of all imported modules

    Tim Michelsen, Mar 10, 2009, in forum: Python
    Replies:
    5
    Views:
    250
    John Machin
    Mar 10, 2009
  5. Fei Liu
    Replies:
    2
    Views:
    1,838
Loading...

Share This Page