in reply to Testing package membership

You can ask with $ref->can('methodname') or yourpackage->can('methodname') if such a method exists (which will not work if AUTOLOAD is in effect, but otherwise it's fine).

can is defined and documented in UNIVERSAL.

Replies are listed 'Best First'.
Re^2: Testing package membership
by FreakyGreenLeaky (Sexton) on Nov 21, 2008 at 09:10 UTC
    Got it! Using ->can() wrapped in eval{} does the trick nicely:
    package Util::Stuff::abc; sub attrib1 { 1 } sub attrib2 { 10 } ... eval { if ($symref->can('attrib1')) { ... $symref->attrib1 is OK ... }};
    Thanks to GrandFather and moritz.
Re^2: Testing package membership
by FreakyGreenLeaky (Sexton) on Nov 21, 2008 at 08:56 UTC
    Hmm, looks like AUTOLOAD is in effect since ->can() is failing.

    Looks like I'm stuck with eval{}, unless there's another way.