Home > Archive > PERL Beginners > March 2004 > use lib
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]
|
|
| B. Fongo 2004-03-26, 11:14 pm |
| Is it recommendable to use the pragma "use lib " when installing a
program on a server shared by many users?
Assuming my IPS did not install certain CPAN modules which my needs, and
I decide to install them in my www directory.
In such a scenario, putting "use lib" on my scripts will add my module
directory to @INC - which in fact isn't desired.
How can I avoid this situation?
Babs
| |
| Jenda Krynicky 2004-03-26, 11:14 pm |
| From: "B. Fongo" <perl@fongo.de>
> Is it recommendable to use the pragma "use lib " when installing a
> program on a server shared by many users? Assuming my IPS did not
> install certain CPAN modules which my needs, and I decide to install
> them in my www directory. In such a scenario, putting "use lib" on my
> scripts will add my module directory to @INC - which in fact isn't
> desired.
1) not sure how do you have this setup, but the directory containing
the modules should not be accessible via web
2) having a
use lib 'something';
in a script affects @INC just for this script. Which in fact is
desired. You need to do so, otherwise the modules would not be found.
You may remove the directory from the @INC after you import the
modules with
BEGIN {shift(@INC)};
(assuming you are sure the directory was NOT present in @INC before!)
but I do not see any reason to do so.
Jenda
===== Jenda@Krynicky.cz === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
| |
| Bob Showalter 2004-03-26, 11:14 pm |
| B. Fongo wrote:
> Is it recommendable to use the pragma "use lib " when installing a
> program on a server shared by many users?
> Assuming my IPS did not install certain CPAN modules which my needs,
> and I decide to install them in my www directory.
> In such a scenario, putting "use lib" on my scripts will add my module
> directory to @INC - which in fact isn't desired.
This is only an issue under mod_perl, where @INC persists across requests
and would thus be shared by multiple scripts.
Under mod_cgi, the changes made by "use lib" affect only the current
process's copy of @INC, so there's nothing to be concerned about.
>
> How can I avoid this situation?
You could try something like this if you're running under mod_perl:
use lib '/my/lib/path';
use MyModule;
no lib '/my/lib/path';
|
|
|
|
|