http://qs1969.pair.com?node_id=697723


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

> Use Moose or another OO framework that allows easy introspection.

Hmm ... but nothing for the old-fashioned plain blessed packages?..

> Without having checked, I think your code will fail to list method in superclasses of $object

You're right :(

> And shouldn't $result be really <c>$object?

Of course it should :)

  • Comment on Re^2: Listing the functions of a package / methods of an object

Replies are listed 'Best First'.
Re^3: Listing the functions of a package / methods of an object
by karavelov (Monk) on Jul 15, 2008 at 16:28 UTC
    Class::MOP (which is the foundation of Moose) works well with the "old-fashioned" plain blessed hashref packages and has the functionality you are looking for. It is provided via Class::MOP::Class method_map.
Re^3: Listing the functions of a package / methods of an object
by moritz (Cardinal) on Jul 15, 2008 at 14:52 UTC
    Hmm ... but nothing for the old-fashioned plain blessed packages?..

    I think you can do better (for example recurse into the classes @ISA, and filter out methods beginning with an underscore (which are private by convention), DESTROY etc.), but there are conceptual limits.

    Perl doesn't have different declarations for subs and methods, so it's impossible to distinguish these two automatically.

    Maybe there are better solutions to your problem. For example the thread Runtime introspection: What good is it? discusses (among a variety of other things) possible alternatives to to introspection.