As I said, ref() should be only used with objects if you really want, explicity, an object blessed in the class FOO, soo, without care about inheritance.

it is poor form to mandate a specific class name for anything except establishing capability. to establish whether a thing can perform only 1 or 2 methods, UNIVERSAL::can( $thing, "doFoo") is more flexible than UNIVERSAL::isa( $thing, "Fooable") besides.

I know that this is possible, as I show in the previous node, what I said is that I never saw this in use! I never saw a code that want's to use the internal object data, HASH, ARRAY,... as a normal data! And I think, that shouldn't be used, since this is not a good thing when we are talking about OO.
try: grep -nr 'isa' /usr/lib/perl | grep -e 'ARRAY' -e 'HASH'

HASH, ARRAY, etc are not internal object data, they are type names in the same way that an object's class name is a type. If i wished to replace all array refs in my code with objects of my shiny new sorted array class with its TIEARRAY interface, i could change only the calling method (to create the object instead of the array ref), put 'ARRAY' into @MySortedArray::ISA as a pseudo-class (read: interface or capability to act as an array), then any code which used UNIVERSAL::isa( $thing, 'ARRAY' ) to establish that $thing could be dereferenced as an array (through its tie interface) would continue to work unchanged, but code using ref( $thing ) eq 'ARRAY' would break and need recoding. and in my company's 170,000 line perl app, recoding hundreds of methods because of bad coding is A Bad Thing and a huge PITA.


In reply to Re: Re: Re: Re: Is "ref $date eq 'ARRAY'" wrong? What a mess! by d_i_r_t_y
in thread Is "ref $date eq 'ARRAY'" wrong? by bronto

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.