in reply to Re^2: Inheritance automation help
in thread Inheritance automation help

I just finished up cleaning up the mess I created. The end result was a combination of using test case registering, and because of the structure and portability of what I'm working with I had to add @ISA for what I was calling the "parent" inside what I was calling the "child". My end result of this discussion took me A LOT further than I ever thought I was going to get with it! This isn't something I would ever do as design, but here is an example in concept of what I did:
#!/usr/bin/perl use strict; use warnings; package Top; sub new { my ($class, %params) = @_; my $self = bless \%params, $class; return $self; } sub firstSub { my ($class) = @_; print "FIRST SUB!\n"; } package Top::Extend1; push @Top::ISA, 'Top::Extend1'; sub addOnSub { my ($self) = @_; print "ADD ON\n"; } package Top::Extend2; push @Top::ISA, 'Top::Extend2'; sub secondAddOn { my ($self) = @_; print "SECOND ADD ON\n"; } package main; my $test = Top->new(); $test->firstSub(); $test->addOnSub(); $test->secondAddOn();
So the way I was saying it was backwards making my question confusing to what my actual goal was. I'm sure this is very "hand slapish" behavior and complicated when it comes to overridden methods... but that was the key to solving my dilemma. Thanks for the help and enlightenment Monks!

Replies are listed 'Best First'.
Re^4: Inheritance automation help
by chromatic (Archbishop) on Apr 17, 2012 at 20:40 UTC

    You might be better off with something like Moose::Role instead of this. Fiddling with someone else's @ISA is a good way to make a mess of fragile code.


    Improve your skills with Modern Perl: the free book.