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';

🦛


In reply to Re^3: Can I learn more about blessed data? by hippo
in thread Where can I learn more about blessed data? by SergioQ

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.