What is the best way to configure parts of an existing Perl program for multiple clients?

I have an existing Perl application that is deployed to multiple client sites. Unfortunately, the code has been cloned several times to configure it for individual clients. So, now there are several complete copies of the code, all of which have small (or large) differences.

My task is to fix this mess by creating a single common code base with settings for different clients isolated in their own libraries.

The application already has a class hierarchy (about 120 classes) line by line:

Control.pm
  \__ BaseJob.pm
           \___Job1.pm
           |
           |__ Job2.pm
           |
           |__ Job3.pm

My goal is to set up a specific class or method by changing only the library for a particular client.

- , . lib ( ). , , .

, Job2.pm, CustomJob2, Job2 , .

:

Job2->some_method();

:

CustomJob2->some_method();

, , CustomJob2 . , CustomJob2 .

?

, , - . use lib, , , , . , , .

StackOverflow .

+5
2

, , ; , Job2- > some_method(), $job- > some_method(). , - , - - , .

, , , , , , , . , :

my $job2_class = $project->conf->{job2_class} || 'Job2';
my $job2 = new $job2_class;
$job2->some_method();
+4

, , .

, , , .

, . .

+4

All Articles