Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: How do I check all the variables, subroutines etc in a Perl Module?

by BillKSmith (Monsignor)
on Aug 31, 2020 at 00:09 UTC ( [id://11121213]=note: print w/replies, xml ) Need Help??


in reply to How do I check all the variables, subroutines etc in a Perl Module?

Lexical variables are not accessible (and may not even exist) outside their scope. Package variables are stored in a symbol table. The symbol table for module (package) is a hash. The keys are the names you seek. The values are references to typeglobs. It is necessary to dereference the typeglob to find out what the name is used for. The details are beyond my experience. The book "Programming Perl" has a lengthy section name "Symbol Tables". It appears to be what you need.
Bill
  • Comment on Re: How do I check all the variables, subroutines etc in a Perl Module?

Replies are listed 'Best First'.
Re^2: How do I check all the variables, subroutines etc in a Perl Module?
by LanX (Saint) on Aug 31, 2020 at 07:55 UTC
    > (and may not even exist)

    For clarification:

    As soon as a sub is compiled, it's lexical vars will "exist". They'll just be undefined outside their scope.

    DB<23> sub foo { my $bar =42 } DB<24> use PadWalker qw/peek_sub/; DB<25> x peek_sub(\&foo) 0 HASH(0x31ffa38) '$bar' => SCALAR(0x31ff828) -> undef DB<26>

    Peeking into file-scoped lexicals might be harder tho.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-04-19 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found