Similar to ref, but only returns the name if the item is a blessed class. In fact there are two subs, one for when you consider qr// constructs to be blessed/objects and one for when you don't. The reason the latter is provided is because a qr// is not really a user defined class type. For some uses this may be a required distinction (I have needed both at times).
Update: For most uses you are probably better off stealing GBARR's solution as posted by jmcnamara in a reply to this node. Thanks jmcnamara and gbarr. :-)
use overload; # required for either
# qr// constructs are NOT considered blessed objects.
sub blessed($) {
(ref($_[0]) && (index(overload::StrVal($_[0]),'=')>=0)
&& overload::StrVal($_[0])!~/^Regexp=SCALAR/)
? ref($_[0]) : ""
}
# qr// constructs ARE considered blessed objects
sub blessed($) {
(ref($_[0]) && (index(overload::StrVal($_[0]),'=')>=0))
? ref($_[0]) : ""
}