I am starting a new project today which is going to have more 200 run modes, and I would
like to break things up.
Next. I suppose I will have one base class which will be called form CGI script.
This class will have only one run-mode, which will load config and determine, which module to load
and which sub to execute.
And here I get stuck... I'm not sure how to do that.
You can load modules at run-time (rather than compile time) by using require();
If you have the module name in a variable you can do
eval "require $module";
Loading modules only when you need them reduces the startup time for CGI scripts,
but if you are using mod_perl or FastCGI, you can probably ignore this and go for the normal use().
You can invoke a sub whose name is in a variable with code like this:
my $name = 'mypackage::mysub';
my $result;
{ no strict;
$result = &$name('parameter');
}You have to use "no strict" because Perl will not allow you to call a subroutine like this otherwise.
The curly brackets limit the effect of "no strict" to just the part that needs it.
If you do not like "no strict", have a look at the Symbol module.
Thilo
--------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[EMAIL PROTECTED]/ http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
