I have to pick a nit. The second one doesn't answer "of the methods that the given class can handle, which ones are defined in the given class?". The (psuedo)code for that would be @local = grep defined &{$class . "::$_"}, $obj->list_all_my_methods. The second one answers the question "of all the symbols in the given class, which ones are names of methods of the given class?".
Case in point:
package Parent;
sub foo { 1 }
package Child;
@ISA = 'Parent';
sub new { bless {}, shift }
$foo = 10;
package main;
my $pkg = "Child";
print join(", ", grep defined &{ $pkg . "::$_" }, keys %{ $pkg . '::'
+}), "\n";
print join(", ", grep $pkg->can( $_ ), keys %{ $pkg . '::' }), "\n";
This prints "new" on the first line, and "new, foo" on the second. I changed the defined() test a bit, because with $pkg in there, it's saying "of the symbols in $pkg, which are defined as functions in this current package I'm in?" rather than "... which are defined as functions in $pkg?".
| [reply] [d/l] [select] |
| [reply] |