in reply to Re: Is reference blessed?
in thread Is reference blessed?
No, that doesn't work.
{ package Foo; use overload '""' => sub { 'Bar' }; sub new { bless({}, shift) } } { my $value = Foo->new; # We want the true type of blessed objects like XML::DOM::Document my $true_type; if(ref($value)) { $true_type = scalar($value); $true_type =~ s/.*=(\w*).*/$1/; } print ref($value)," is really an $true_type\n"; }
Foo is really an Bar
But it's really a hash.
Scalar::Util's blessed, reftype and refaddr provide the desired $class, $type and $addr respectively.
|
---|