no strict 'refs'; for(keys %Foo::) { # All the symbols in Foo's symbol table print "$_\n" if exists &{"Foo::$_"}; # check if symbol is method } use strict 'refs';
或者,要获取所有方法的列表:
no strict 'refs'; my @methods = grep { defined &{$_} } keys %Foo::; use strict 'refs';