I'm still new to the OO thing, so I'm not exactly sure what you are looking for here, but since you have the book, you might want to take another look at the chapter on inheritance. I believe you can inherit the whole kit and kaboodle in some kind of initiatizable class or something. e.g.

package _Initializable; sub new { my ($self,$args); my $private_stuff = "private"; my $class_data = { do stuff here "class_data" => $private_stuff}; bless $class_data, ref($class)||$class; $self->_init($args); # pass them back to the calling mod }
And then you'd call it like:
use _Initializable; package Caller; # suck "new" in from _Initializable, along with our # data private to object Caller when we call # $foo=Caller->new($arg) elsewhere @Caller::ISA = qw(_Initializable); # no "new" constructor in any of our stuff... we use _init # to do "construction" # now so that we inherit from _initializable # obviously if you want to provide a class method in # _Initializable for the private data, that wouldn't be too # difficult. sub _init { my ($self,$arg) = @_; do other stuph return $self; }

As I understand it, any method you put in _Initializable (or any other module you inherit, for that matter) is masked if you make a method with the same name as the one in _Initializable. As I say, I'm pretty new to the whole concept of OO, so I may have completely missed the point. As you can see, most of this is a complete crib from Conway's book, chapter 6.


In reply to RE: opinions on the best way to inherit class data by tenatious
in thread opinions on the best way to inherit class data by d_i_r_t_y

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.