List all packages in a file.pm

Discussion in 'Perl Misc' started by gupit@yahoo.com, Sep 27, 2005.

  1. Guest

    Hi,
    If I have multiple packages in the same file, how do I list all the
    packages in that file?

    State.pm:
    --------------------------------------
    pacakage State;
    # abstract class for defining interface

    sub factory { ... }
    sub new { ... }
    sub execute { die "never reach here\n"; }

    package StateBegin;
    use base qw(State);
    sub execute { # do setup; # change state to StateStep1 }

    package StateStep1;
    use base qw(State);
    sub execute { # do step1 processing; # change state to StateStep2 }

    package StateStep2;
    use base qw(State);
    sub execute { # do step2 processing; # change state to StateEnd }

    package StateEnd;
    use base qw(State);
    sub execute { # done }


    I want to list all the possible states the script can be in
    prgrammatically.
    %INC only lists State.pm.

    Thx.
    , Sep 27, 2005
    #1
    1. Advertising

  2. Guest

    Never mind. I can iterate through %::main and get the list of
    namespaces.
    Thx.
    , Sep 27, 2005
    #2
    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. Paul  Smith
    Replies:
    0
    Views:
    730
    Paul Smith
    Nov 18, 2003
  2. alf
    Replies:
    1
    Views:
    262
    Fredrik Lundh
    Nov 2, 2006
  3. David Lyon
    Replies:
    19
    Views:
    573
    David Lyon
    Apr 24, 2009
  4. Jabba Laci
    Replies:
    0
    Views:
    246
    Jabba Laci
    Sep 13, 2011
  5. Ian
    Replies:
    3
    Views:
    168
Loading...

Share This Page