I got a little further with this, and feel a little better about it. I think what it comes down to is that I was trying to do something that inheritance isn't able to accomplish innately - and for some reason I thought I could wiggle it around to get it to work. Here is another concept I was working on to accomplish the above goal:
use Top; my $test = new Top (Foo=>'Start Foo'); use Top::Extend1; $test = plugin Top::Extend1 ($test, %settingsScopedToExtend1); use Top::Extend2; $test = plugin Top::Extend2 ($test, %settingsScopedToExtend2);
The passing of test to each one holds the class, it gets mashed together, altered slightly depending on what the Extend class is doing and passed back to $test with extra methods attached and altered class variables. The end result is that I needed to append classes to each other. So at any time I can call my base class and have new methods that were not there before, but were added because of calling its constructor named plugin that does a "cloneish" concept. Feel free to let me know if I'm off my rocker on doing something like this! Or there is a GOTCHA that I'm not thinking of that isn't obvious like accidental overwriting of methods and such. Also here is an example of what the Extend1 plugin constructor would look like in the Extend1 Package:
sub plugin { my ($class, $other, %params) = @_; # # bless my new combined class # $other = bless $other, $class; # # set defaults scoped to Extend1 # $other->{"Extend1"}->{"someSetting"} = 'its value'; # # overwrite defaults # @{$other->{"Extend1"}}{keys %params} = values %params; # # update any $other data # $other->{'Foo'} .= ' Appended to it '; # # pass back our extended class # return $other; }

In reply to Re: Inheritance automation help by natelewis
in thread Inheritance automation help by natelewis

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.