Background
I have a perl script, called main.pl that is currently in several branched states on clear case like so:
Branch 1:
my %hash
my $variable = "a"
my $variable2 = "c"
sub codeIsOtherwiseTheSame()
....
Branch 2:
my %hash2
my $variable = "b"
sub codeIsOtherwiseTheSame()
....
Branch 3
my %hash
my $variable2 = "d"
sub codeIsOtherwiseTheSame()
....
Right now, each branch of the script has the same code. The only differences are the kind of variables that are declared and what their initialized value is. What I want to do is extract these differing variables out to a wrapper script (for each variation) so that the main script does not have to be changed. I am doing this because several users will be using this script, but have only minor differences based on their use case. Thus I want each kind of user to have their own simplified interface. At the same time, I want the main script to still be aware of these variable once it is called. Below is an example of what I want:
Desired Solution
Wrapper Script 1:
my %hash;
my $variable = "a";
my $variable2 = "c";
system("main.pl");
Wrapper Script 2:
my %hash2;
my $variable = "b";
system("main.pl");
Wrapper Script 3:
my %hash;
my $variable2 = "d";
system("main.pl");
Main.pl
sub codeIsOtherwiseTheSame()
Question
How do I extract out a wrapper script to obtain the organization and behavior I want above?