Ok, so I have a class that I'm having a hard time designing properly with inheritance, and I feel confused dealing only with inheritance in OOP in other languages (C++, Java). My only resource isn't much help unfortunately, so I definitely need some Perl-y wisdom from some knowledgeable people right now.

My use model is to have a base class, develop multiple derived classes, piece together the final product as the sum of all of the inherited derived classes, then validate the sum in the final stage prior to executing it. This is being done to reduce maintenance on 30~75+ derived class modules.

So far my class looks something like the following:

#================= # Main require model::MAKE_BASIS; #================= # The following can live in model/MAKE_BASIS.pm package model::MAKE_BASIS; our @ISA= ( qw(Master_Classes::Make pm::Section), @ISA); use Data::Dumper; use pm::Section; $RULES = inheir_merge( exports => { # Environment variables to export at program's runtime. }, opts => { # A hash of options that get passed into a program. }, # Time limit for execution timeout => 12 ); #================= # The following lives in pm/Section.pm package pm::Section; use Data::Dumper; use qw(Exporter); our @ISA = qw(Exporter); our @EXPORT = qw(import inheir_merge); our @EXPORT_OK = qw(import inheir_merge); sub new { my $this = shift; my $class = ref($this) || $this; my $self = { # Empty definition just for example }; bless $self, $class; $self->validate(); } sub import { __PACKAGE__->export_to_level(1, qw(inheir_merge initialize)); } sub inheir_merge { my $class = ref(caller()) || caller(); my $self = {}; bless $self, $class; $self->SUPER::inheir_merge(@_) if($self->SUPER ne __PACKAGE__ +); }

However, when I try and run this piece of code I come up with a message stating:

"Undefined subroutine &model::MAKE_BASIS::inheir_merge"

I'm not sure why this is occurring though because I used use Exporter and all the symbols are being exported properly AFAIK.

Could anyone try and provide a suggestion to either redesign my class or approach the problem that could solve this particular issue?

I greatly appreciate your help.

-Garrett


In reply to 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.