in reply to Remove bless reference or class/package name from method arguments

shift if ref $_[0] eq __PACKAGE || $_[0] eq __PACKAGE__;

That's a bad idea because it breaks inheritance. I'd do this instead:

shift if eval { $_[0]->isa(__PACKAGE__) }:

Replies are listed 'Best First'.
Re^2: Remove bless reference or class/package name from method arguments
by binf-jw (Monk) on May 20, 2009 at 10:43 UTC
    That did cross my mind thanks.
    Would you need to implement a custom isa method that searches @ISA?
    Or is there a built in? can't find anything on perldoc.
    John,
      The isa method is already there, provided by the UNIVERSAL class, and can be called without any further ado:
      $ perl -wle 'print +(bless {})->isa("main")' 1