Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Listing the functions of a package / methods of an object

by friedo (Prior)
on Jul 15, 2008 at 14:44 UTC ( #697733=note: print w/replies, xml ) Need Help??


in reply to Listing the functions of a package / methods of an object

You don't have to use eval to get the keys of the package's symbol table, just do
my @subs; { no strict 'refs'; my $st = $class . '::'; @subs = keys %$st; }

Unfortunately, there's no way to differentiate between methods and regular subroutines, and as moritz pointed out, that won't find inherited methods which exist in different packages. Moose's metaclass facilities are really great, but naturally they only work for objects that are built with Moose.

There is Class::Inspector, which has a reasonably good function to search a class's @ISA tree and get a list of every possible inherited method.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://697733]
help
Chatterbox?
[huck]: "and all is quiet..." "Others having an uproarious good time at the Monastery" ... something seems not quite right ...
[huck]: just the first time i noticed the "uproarious" message ... i must be bored

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2017-02-24 03:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (351 votes). Check out past polls.