in reply to What package is the method in?

Untested:
my @classes = ref $foo; my $method = "do_stuff"; while (@classes) { my $class = shift @classes; no strict 'refs'; if (defined &{"${class}::${method}"}) { say $class; exit; } unshift @classes, @{"${class}::ISA"}; } say "Not found";
This doesn't catch cases where a method is dealt with by an AUTOLOAD function.

Replies are listed 'Best First'.
Re^2: What package is the method in?
by ikegami (Patriarch) on May 14, 2010 at 14:15 UTC

    You're making bad assumptions about the mro.

    And defined should be exists. sub f; will "handle" the method call, but you look pass it.