For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > February 2005 > modulespath via environment-variable ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author modulespath via environment-variable ?
Felix Drueke

2005-02-21, 8:56 am

Hi,

is it possible to specify an alternative modules-path via environment-
variable?

The reason I ask is:
we are developing a product that uses perl and some perlmodules.
We want that the modules are installed in the developers workspace
from the source-control-system and not host-wide in /usr/local/lib/perl5.
We want that the perlmodules are part of the product.

As we already have many perl-scripts I just want to be able to set
an environment-variable (in a "PERLHOME"-style) in order to tell all
of them that they should search in that path for modules.

Thanks for any hints,
Felix
Brian McCauley

2005-02-21, 3:57 pm

Felix Drueke wrote:

> is it possible to specify an alternative modules-path via environment-
> variable?


Yes.

> Thanks for any hints,


The a list of environment variables that can effect Perl can be found in
the reference manual. Actually they are not quite all in one place but
searching for the string "ENVIRONMENT" in the table of contents will
find them quickly.

Big and Blue

2005-02-21, 8:56 pm

Felix Drueke wrote:
>
> is it possible to specify an alternative modules-path via environment-
> variable?


Yes, but there are other ways to do it too, and better ones.

> we are developing a product that uses perl and some perlmodules.
> We want that the modules are installed in the developers workspace
> from the source-control-system and not host-wide in /usr/local/lib/perl5.
> We want that the perlmodules are part of the product.


Then make them part of the product. Get the product to add:

use lib qw( dir-path1 dir-path2 etc );

at the beginning of each script.

> As we already have many perl-scripts I just want to be able to set
> an environment-variable (in a "PERLHOME"-style) in order to tell all
> of them that they should search in that path for modules.


However, if you do that in a global environment variable (PERL5LIB)
then *all* perl usage will start looking in those locations, which isn't
what you want.

You could also write a script interlude which execs the "real" perl,
having inserted relevant -Idir... options at the start of the argument
list. Then get the scripts to use this interlude in the #! line.


> Thanks for any hints,


Application settings go with an application, not the global system.



--
Just because I've written it doesn't mean that
either you or I have to believe it.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com