in reply to Moose: get class name
Does not ref $self work, just like for regular perl objects?
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.sub role_action { my $self = shift; my $obj_type = ref $self; # ... }
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Moose: get class name
by kcott (Archbishop) on Nov 10, 2010 at 18:00 UTC |