christopherbarsuk has asked for the wisdom of the Perl Monks concerning the following question:
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:
if( index( $ENV{SCRIPT_NAME}, '/dev/' ) == -1 ) { use lib "/blah/perllib/"; } else { use lib "/blah/perldev/"; }
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...
Any thoughts?
--christopher@barsuk.com
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: dynamically loading modules/maintaining dev v. prod modules
by wog (Curate) on Jul 28, 2001 at 03:16 UTC | |
Re: dynamically loading modules/maintaining dev v. prod modules
by PrakashK (Pilgrim) on Jul 28, 2001 at 03:01 UTC | |
Re: dynamically loading modules/maintaining dev v. prod modules
by traveler (Parson) on Jul 28, 2001 at 18:59 UTC | |
Re: dynamically loading modules/maintaining dev v. prod modules
by HyperZonk (Friar) on Jul 28, 2001 at 03:01 UTC | |
Re: dynamically loading modules/maintaining dev v. prod modules
by John M. Dlugosz (Monsignor) on Jul 29, 2001 at 00:26 UTC | |
by Random_Walk (Prior) on May 29, 2006 at 11:26 UTC | |
by John M. Dlugosz (Monsignor) on Jun 01, 2006 at 19:26 UTC | |
by Random_Walk (Prior) on Jun 04, 2006 at 11:03 UTC |