Since you're asking about methods and not plain subs, i.e. inheritance plays a role, I believe what you are looking for is UNIVERSAL's can.
{ package Foo; sub foo {} } { package Bar; use parent -norequire, 'Foo'; sub bar {}; } print Foo->can('foo')//'undef', "\n"; print Foo->can('bar')//'undef', "\n"; print Bar->can('foo')//'undef', "\n"; print Bar->can('bar')//'undef', "\n"; __END__ CODE(0x1343fa8) undef CODE(0x1343fa8) CODE(0x1343b68)
Update: If you don't want to take inheritance into account and just want to know if a certain subroutine has been defined in a specific package, you can use defined(&Package::subroutine).
In reply to Re: How to determine if a sub is defined in a package, without calling it?
by haukex
in thread How to determine if a sub is defined in a package, without calling it?
by lamber45
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |