Hello,

I've been toying around with perl 5.9.4. Just testing out some of the new features. One of those feature I don't understand is UNIVERSAL::DOES(). I've read the perldelta for perl 5.9.4 and the newest edition of The Perl Review which a has an article on perl 5.9.4, but I'm still not getting it. I don't see how it is difference from ISA. Here is some test code I wrote.

#!/opt/bleadperl/bin/bleadperl package Role; package Object; @Object::ISA= ('Role'); sub new { my $class = shift; return bless {}, $class; } package main; my $o = Object->new(); print 'Object DOES Role' if $o->DOES(Role);

I don't see how this is really different than using ->isa(). I understand how roles work in Class::Traits and Moose, but I don't have to use @ISA to setup the relationship. I think i'm missing soming basic or I really don't understand how roles or traits are supposed to work. Can someone point me in the right direction?

Thanks,


In reply to I don't understand UNIVERSAL::DOES() by rlb3

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.