home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!convex!convex!tchrist
- From: Tom Christiansen <tchrist@convex.COM>
- Subject: Re: how to find all current package names?
- Originator: tchrist@pixel.convex.com
- Sender: usenet@news.eng.convex.com (news access account)
- Message-ID: <1992Sep14.000832.10143@news.eng.convex.com>
- Date: Mon, 14 Sep 1992 00:08:32 GMT
- Reply-To: tchrist@convex.COM (Tom Christiansen)
- References: <17597@autodesk.COM>
- Nntp-Posting-Host: pixel.convex.com
- Organization: Convex Computer Corporation, Colorado Springs, CO
- X-Disclaimer: This message was written by a user at CONVEX Computer
- Corp. The opinions expressed are those of the user and
- not necessarily those of CONVEX.
- Lines: 28
-
- From the keyboard of dansmith@Autodesk.COM (Daniel Smith):
- :
- : 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
- --
- Tom Christiansen tchrist@convex.com convex!tchrist
-
- It is, of course, written in Perl. Translation to C is left as an
- exercise for the reader. :-) --Larry Wall in <7448@jpl-devvax.JPL.NASA.GOV>
-