As already noted, no, you can't bless a reference into more than one class, but this sounds like it has strong potential as a use case for Moose roles. @ISA is the only form of inheritance (single or multiple) recognized by the Perl interpreter.

Now, as for why you can't bless a reference into more than one class, you need to think about how Perl OO works in the first place:

A Perl "object" is actually just a reference which is associated (via bless) with the namespace of a certain package. (This package is commonly referred to as a "class", but, really, it's just a namespace.) This association tells perl that any subroutines accessed by way of the blessed reference should be resolved within the connected package's namespace, passing the reference itself as the first argument. You can't be in more than one namespace at a time, therefore a reference can't be blessed into more than one "class" at a time.

One way that you might be able to do what you're thinking about ("might" because I don't completely follow your intent) within normal Perl OO would be to access the inherited methods directly by their packages. There's not really anything special about SUPER, so if you have something that's both a Vehicle::Car and a Vehicle::Airplane, you can save it to both classes by calling both Vehicle::Car::save($self) and Vehicle::Airplane::save($self).


In reply to Re: Multiple Inheritance (DBIx::Class) by dsheroh
in thread Multiple Inheritance (DBIx::Class) by Cybris

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.