in reply to Re: A class that cannot be subclassed.
in thread A class that cannot be subclassed.

I think the initial test in selfcheck should be:

sub selfcheck { my $self = shift; die "..." if ref $self ne __PACKAGE__; # lineage check... }

As you have it, the test would always pass because __PACKAGE__ is the package that the sub was compiled in (Foo::Bar) regardless of anything else (see perlmod).

If I were a "malicious subclasser" faced with this, I could redefine selfcheck (I think), and then it's smooth sailing. What you could do is put that in a lexical subref, then it would stay private.

package Foo::Bar; # ... my $selfcheck = sub { my $self = shift; die ... }; sub method { my $self = shift; $selfcheck->( $self ); # ... }

I'm not sure where to go from there. Putting that check seems like a lot of work for the goal, but I guess it could be worse.