[Chicago-talk] Dynamic @INC builder?
Steven Lembark
lembark at wrkhors.com
Fri Jan 23 17:29:13 CST 2004
-- Don Drake <don at drakeconsult.com>
>
> My current project has a lot homemade perl modules and scripts that use
> these modules.
>
> I ran into the same problem with a development server, multiple developers
> and a production server -- all with different paths to the location of our
> scripts and modules.
>
> First, everything is stored under a single "root" directory, e.g.
> "/home/drake/falconperl" for dev, and "/data0/falcon" for prod.
> Furthermore, all perl libraries are located in /lib under the "root"
> (/data0/falcon/lib).
>
> The way I have it setup is with a single environment variable
> (FALCON_HOME) which is set in the users profile.
>
> No module is required, only requirement is that the environment variable
> is set.
>
> I then use the following at the top of every script:
> use lib "$ENV{FALCON_HOME}/lib";
> ...
> use PCS::Nortel;
>
> If the environment variable isn't set (or set incorrectly), nothing works.
>
> It's not as dynamic as FindBin::libs, but that's OK. Having a script
> "hunt down" libraries can be viewed as helpful or hurtful depending on
> the library it found, e.g. my home directory contains many old versions
> of installed perl modules I don't want it looking there!.
>
> Being explicit with a environment variable ensures a more predictable
> outcome.
At that point Aaron has the simplest fix: use PERL5LIB. The
ultimate way to be lazy: perl's already done it for you :-)
If you want to store things under a root directory then
simply symlink it into your sandbox:
./sandbox
lib -> /root/lib/path
./project
your stuff here.
Anything in ./sandbox/lib will be avaiable to ./sandbox/project/whatever.
Nice thing about this is that you can work on one of the lib's by putting
it into ./sandbox/lib-developdir and use that to override the defaults.
Makes maint. development and regression testing a whole lot easier.
--
Steven Lembark 2930 W. Palmer
Workhorse Computing Chicago, IL 60647
+1 888 359 3508
More information about the Chicago-talk
mailing list