how to find all current package names? 
Author Message
 how to find all current package names?

        You have a script.  You've included some libraries,
so you have more than just %_main.  Now, how would you find out
the names of all of the current packages?

        What I'm up to:

        In SoftList 3.0, which I'm working on, I have a "dumpv"
alias that can be invoked from the Perl CLI, and it shows the
state of everything in %_main (via dumpvar.pl).  I would like to be able
spit out a list of packages so that the user could give dumpv a
"which package" argument.

                                Daniel

p.s.  If you want to check out SoftList (the CLI part is in better
shape than the list handling), email me, and I'll send you the beta.
I have most of the command line editing you'd find in tcsh.
--
     Daniel Smith, Autodesk, Sausalito, California, (415) 332-2344 x 2580
              Disclaimer: written by a highly caffeinated mammal



Fri, 03 Mar 1995 05:47:05 GMT  
 how to find all current package names?

:
:       You have a script.  You've included some libraries,
:so you have more than just %_main.  Now, how would you find out
:the names of all of the current packages?

This will get you 99.9% of the way. it would miss some pathological cases
that you probably can't generate without trying really hard, such as
package names that aren't valid identifiers.   But if you're doing that,
you'll probably understand how to modify this code to find them, too.

    foreach $package (keys %_main) {
        next unless $package =~ /^_/;
        $val = $_main{$package};
        next unless $val =~ /^StB/;
        *stab = eval("*$package");
        foreach $ident (keys %stab) {
            print substr($package, 1)."\n" if $stab{$ident} =~ /^StB/;
            last;
        }
    }

--tom
--

    It is, of course, written in Perl.  Translation to C is left as an



Fri, 03 Mar 1995 08:08:32 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Returning the name of the current package?

2. Finding name of current directory in Perl

3. How to find name of currently executing package?

4. Name space switching using variable package names

5. our() limited to current package?

6. Current package

7. Inheritance and blessing into the current package

8. Current package detection

9. Newbie warning: How to place current directory name into variables

10. looking for current directories name

11. Getting the current directory path/name

12. Current Directory Name

 

 
Powered by phpBB® Forum Software