Dogma
12-10-2001, 01:27 AM
I want to load a perl script based on a users choices. At the moment I was using require to import the script into another and execute it from there. One problem has arisen. When mod_perl caches the original script it also caches the initial require script, as a result only the script only really works the first time it is run. Any suggestions?
klamath
12-10-2001, 08:57 PM
Um, what? Are you using Apache::Registry, Apache::PerlRun, and plain a plain Apache handler?
Loading a Perl script dynamically is almost certainly a bad idea. Because you have a bunch of Apache children, each child will likely have to service this request at least once; that means that each child will have a full copy of both scripts in memory. That means memory bloat. If you pre-load all the scripts on startup, they will be shared by all the Apache children so they only need to be stored in memory once (well, writable memory will need to be per-process, but the majority will be shared). I'd say: write the code as a Perl object or a regular module (.pm); load the 2 modules via the PerlModule directive, or in your Perl init script. And then in your code, run a different subroutine or instansiate a different object depending on what the user selected.