|Keep It Simple, Stupid|
dynamically loading modules/maintaining dev v. prod modulesby christopherbarsuk (Acolyte)
|on Jul 28, 2001 at 02:56 UTC||Need Help??|
christopherbarsuk has asked for the
wisdom of the Perl Monks concerning the following question:
I've tried a gazillion different ways of doing this, none with very much success. Surely, there must be a way, and surely there are people doing similar things out there...
Background: I maintain a set of CGI scripts which use a bunch of perl modules. Each module is kept in two different places -- production vs. development. The CGI scripts are also kept in two different places (prod vs. dev).
I want to do something like this:
so that if the CGI script is being called from a DEV environment, it will load the DEV modules; if the script is called from a PROD environment, it will load the PROD modules. This way, my CGI scripts can be identical (even though they're kept in two separate directories).
The method above isn't working, however, presumably because the 'use' pragma is evaluated at compile time, before $ENV has a value.
What other tricks are there whereby I might accomplish what I'm after? Basically, I want my source files to load the appropriate modules depending on where they're located...