Mutant has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
I've got a mod_perl handler that, based on the Location of the request, loads a sub-class, and calls methods off that class rather than the base class to do all it's processing, ie something like this:
my $class = 'Class::Base'; if ($has_sub_class) { $class = 'Class::' . $sub_class_name; eval("require $class"); } my $object = $class->new; $object->do_stuff;
I've done it this way because there will potentially be hundreds of different sub-classes, so I don't want to load them all every time.
My question is two-fold. Firstly, is this a sane way to do it?
And secondly, what effects will this have? ie, Even though the class will be loaded on demand, I'm guessing the memory won't then be freed from the Apache process once the request has been made. Will this have an effect on performance other than just memory usage? Any ideas on tweaking Apache to minimise this?
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Run time require's and mod_perl
by ides (Deacon) on Nov 22, 2004 at 17:10 UTC | |
|
Re: Run time require's and mod_perl
by perrin (Chancellor) on Nov 22, 2004 at 17:10 UTC | |
|
Re: Run time require's and mod_perl
by ikegami (Patriarch) on Nov 22, 2004 at 17:11 UTC |