I'm trying to develop a framework for an application, and i've gotten stuck at a certain point. First, let me layout the basic idea behind the app.
The idea behind the app is to provide a framework which groups can extend on their own. The framework is supposed to provide a few basic functions and then call the functions the group is interested in. Each group will have a list of functions they want to run. They may want to use functions written by other groups.
I've currently prototyped this using multiple files, one for the primary program, and one for each group, and i'm including the group files. What I'd like to do is add the ability for users to prototype functions by writing the function in a side file and let them test it before adding it to the group files.
I can't seem to find a way to extend this cleanly to allow user to test code before they turn it into the global files. Am I approaching this problem the wrong way or is there a way to do everything I want?
Example code:
#file: test
use strict;
use warnings;
use group1_func;
my %run_list;
my $group = $opt_group; #this is just for simplicity for this example
if ($group eq "group1") { %run_list = GROUP1_run_list; }
else { die "Bad Group\n";}
foreach my $func (keys %run_list) {
$run_list{$func}->();
}
#file: group1_func.pm
package group1_func;
use strict;
use Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@EXPORT = qw(G1_func1, G1_func2);
our %run_list = ( "G1_func1" => \&G1_func1, "G1_func2" => \&G1_func2);
sub G1_func1 {
print("G1_funct1 called\n");
}
sub G1_func2 {
print("G1_func2 called\n");
}
1;
The idea behind the app is to provide a framework which groups can extend on their own. The framework is supposed to provide a few basic functions and then call the functions the group is interested in. Each group will have a list of functions they want to run. They may want to use functions written by other groups.
I've currently prototyped this using multiple files, one for the primary program, and one for each group, and i'm including the group files. What I'd like to do is add the ability for users to prototype functions by writing the function in a side file and let them test it before adding it to the group files.
I can't seem to find a way to extend this cleanly to allow user to test code before they turn it into the global files. Am I approaching this problem the wrong way or is there a way to do everything I want?
Example code:
#file: test
use strict;
use warnings;
use group1_func;
my %run_list;
my $group = $opt_group; #this is just for simplicity for this example
if ($group eq "group1") { %run_list = GROUP1_run_list; }
else { die "Bad Group\n";}
foreach my $func (keys %run_list) {
$run_list{$func}->();
}
#file: group1_func.pm
package group1_func;
use strict;
use Exporter;
use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@ISA = qw(Exporter);
@EXPORT = qw(G1_func1, G1_func2);
our %run_list = ( "G1_func1" => \&G1_func1, "G1_func2" => \&G1_func2);
sub G1_func1 {
print("G1_funct1 called\n");
}
sub G1_func2 {
print("G1_func2 called\n");
}
1;