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.

Yes, that is essentially what I'm trying to do.

Specifically, I'm working on an API for Samba 4 Active Directory using Net::LDAP. The API is meant to abstract much of the LDAP code needed to query the AD. For example, you could ask the api:

@posix_users = $ad->listObjects('users','posix');

And then the API would spit out the requested data. The problem I was running into is that the over all perl module was getting large in size, so I thought I'd try and spin off some of the methods to sub-classes. Good examples are those methods associated with users would get a module: Users.pm. And then those associated with groups, Groups.pm.

So my module structure looks like this:

esmith::AD (AD.pm)
- esmith::AD::Users (Users.pm)
- esmith::AD::Groups (Groups.pm)

The methods in Users.pm and Groups.pm really do specialize active directory objects generated in the parent module. Following your example, a user ISA object.

So the primary reason for wanting the parent class to see the child class methods, we me being lazy, I think.

Lazy Code (child method called from parent constructor): use esmith::AD; use strict; my $ad=esmith::AD->new(); warn "User exists\n" if ($ad->doesUserExist('greg')); Proper code (child method called from child constructor): use esmith::AD::User; use strict; my $ad=esmith::AD::User->new(); warn "User exists\n" if ($ad->doesUserExist('greg'));

Is this more along the lines that you were trying to explain?

In reply to Re^2: Method of child module called by parent by gzartman
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.