Why are you exporting a method from a base class to an inheriting class? Normally you either export, or you inherit.

Why are you exporting your import() method?

Why are you even defining an import() method when the one you're inheriting from Exporter should work fine and yours does not? I.e. remove the import() method and fix the obvious syntax errors and you can use your inheir_merge() method from the use()ing package.

Why are you creating an an object of the caller's class to to call SUPER on when you can call caller()->SUPER::inheir_merge() directly?

And finally, what is all this supposed to do that you can't solve with straightforward (mutiple or single) inheritance?

update: ah, I see a bit more. You'll probably just want to export properies. Since all of your properties seem to be class -based (i.e. no object-specific properties) you can for instance declare them as methods:

Flies: Earthbound = 0; Machine: Metallic = 1; Warm-blooded: Blood = "warm"; Kryptonian: Weakness = "Kryptonite";
package Base; # define default values sub earthbound { 0 } sub metallic { 0 } sub blood { "cold" } sub weakness { undef } # update 2: sub validate { my ($class) = @_; return ($class->blood eq 'warm' or ! $class->metallic); } # define 'mixins' - don't subclass these, # they'll export their properties when you use them package Flies; use base Exporter; our @EXPORT = qw(earthbound); sub earthbound { 1 } package Robot; use base Exporter; our @EXPORT = qw(metallic); sub metallic { 1 } # etc... package Superman; use base Base; use Flies; use Robot; # superman's very metallic.

In reply to Re^3: Dealing with design -- inheritance + exporting gone bad :(.. by Joost
in thread Dealing with design -- inheritance + exporting gone bad :(.. by yaneurabeya

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.