Does not ref $self work, just like for regular perl objects?
sub role_action
{
my $self = shift;
my $obj_type = ref $self;
# ...
}
I don't think this is any different. __PACKAGE__ never tells you the class name for the object you're working with, it only gives you the package that you're currently in, which is not the same thing at all if you're in a package that can be inherited from.
Update: the difference between ref and blessed on $self is probably moot since if $self isn't a reference to a blessed object, either you won't be here or you're probably about to blow up badly anyway. For objects other than $self, there's a bigger difference. |