Hello gzartman, and welcome to the Monastery!

I'd like to be able to call methods from the child class as if they were in the parent class

You have that back-to-front! Child classes inherit from their parents; parent classes ought to have no knowledge of their children. So when you have code like this:

package parentClass; use parentClass::childClass;

it’s almost always a symptom of a faulty OO design.

I've been working on a perl module and found that it was getting a big unwieldy, so decided to spin off a few child classes to my main class to help organization and what not.

A child class specialises its parent in a way that makes for an asymmetrical ISA relationship. For example, owl specialises bird, because an owl ISA bird (but a bird is not necessarily an owl). So, anything a bird can do, an owl can do too (but most likely in a distinctively owlish way). And an owl can do things other birds can’t: for example, $owl->hunt_at_night() or $owl->hoot() make a lot more sense than $sparrow->hunt_at_night() or $sparrow->hoot(). So it makes little sense to give hunt_at_night or hoot methods to package bird; and still less sense to try to allow a bird (which could be an eagle, a toucan, or a dodo) to hoot in the way owls do!

I suspect what you’re looking for is a helper class which your parent class accesses via a HASA or USES relationship. But in the absence of concrete details it’s hard to give more definite advice.

By the way:

  1. Please put your code in <code> ... </code> tags; see Markup in the Monastery.

  2. The standard convention is to begin a package name with an uppercase letter: ParentClass, ParentClass::ChildClass;.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: Method of child module called by parent by Athanasius
in thread Method of child module called by parent by gzartman

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.