To determine if any reference is blessed or not, I would highly recommend Ref::Util's is_blessed_ref() subroutine. That is precisely what it is designed for.
I strongly suspect that determining the blessedness of a given reference is not what SergioQ was actually enquiring about, however.
Update: sample test set to show it in action. You can throw anything at it and it won't complain - just return true if the arg is a blessed ref and false otherwise.
use strict;
use warnings;
use Ref::Util 'is_blessed_ref';
use Test::More tests => 9;
ok ! is_blessed_ref (undef), 'No: undef';
ok ! is_blessed_ref (0), 'No: false';
ok ! is_blessed_ref (1), 'No: true';
my ($x, @x, %x);
ok ! is_blessed_ref (\$x), 'No: scalar ref';
ok ! is_blessed_ref (\@x), 'No: array ref';
ok ! is_blessed_ref (\%x), 'No: hash ref';
bless \$x, 'Foo';
bless \@x, 'Foo';
bless \%x, 'Foo';
ok is_blessed_ref (\$x), 'Yes: blessed scalar ref';
ok is_blessed_ref (\@x), 'Yes: blessed array ref';
ok is_blessed_ref (\%x), 'Yes: blessed hash ref';
|