Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Accessing list of package names in a module

by LanX (Saint)
on Nov 20, 2008 at 10:03 UTC ( [id://724831]=note: print w/replies, xml ) Need Help??


in reply to Accessing list of package names in a module

Just one remark for better understanding: Each imported package is listed in the namespace symbol table of the importing package.

so by scanning the namespaces starting from the root "main" you should find the desired infos. Packages are keys ending with a "::".

use Data::Dumper; print Dumper \%:: ;
you will see entries like 'Data::' => *{'::Data::'},

so recursively you can get all the infos you want.

Cheers LanX

UPDATE:

Note:

  • %:: is a abbreviation for %main::
  • "%packagename::" is known as "stash" = symbol table hash

Replies are listed 'Best First'.
Re^2: Accessing list of package names in a module
by FreakyGreenLeaky (Sexton) on Nov 20, 2008 at 10:43 UTC
    Aah, that's the one. Nice and simple and takes advantage of goodies hidden internally . Thank you!
      Symbol tables are hardly "goodies hidden internally", they are documented in perlmod.

      Though if you come from other programming languages it's not obvious that something like that even exists :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://724831]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-03-28 22:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found