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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |