How can I subclass 2 separate instances of 2 modules that inherit and use the same base. Similar to a factory class but separate instances for each call. I'm looking at using this approach for a module in mod_perl, fcgi, cgi and pl environments.

I've written out a basic outline of what I'd like to do below.

Thank you in advance for your thoughts, suggestions and help.
Jack

package BasicX; sub new { ... } sub someMethod1 { ... } sub someMethod2 { ... } 1; # --------------------------- package BasicX::AAA1; use BasicX; sub new { my $class = shift; my $args = shift; my $newclass = BasicX->new( { DEBUG => $args->{DEBUG}, SETTTING1 => $args->{SETTING1}, } ); return $newclass; } 1; # --------------------------- package BasicX::BBB1; use BasicX; sub new { my $class = shift; my $args = shift; my $newclass = BasicX->new( { DEBUG => $args->{DEBUG}, SETTTING1 => $args->{SETTING1}, } ); return $newclass; } 1; # ------------------------------- script.pl ---------- #!/usr/bin/perl use BasicX::AAA1; use BasicX::BBB1; my $ObjAAA = BasicX::AAA1->new( { DEBUG => 1, SETTING1 => "this is it" + } ); my $ObjBBB = BasicX::BBB1->new( { SETTING1 => "separate value" } ); $ObjAAA->someMethod(); ...

In reply to Multiple instances of the same base class by jck000

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.