How do I list available methods on a given object or package in Perl?

Benoît picture Benoît · May 26, 2009 · Viewed 19.4k times · Source

How do I list available methods on a given object or package in Perl?

Answer

Nic Gibson picture Nic Gibson · May 26, 2009

There are (rather too) many ways to do this in Perl because there are so many ways to do things in Perl. As someone commented, autoloaded methods will always be a bit tricky. However, rather than rolling your own approach I would suggest that you take a look at Class::Inspector on CPAN. That will let you do something like:

my $methods =   Class::Inspector->methods( 'Foo::Class', 'full', 'public' );