[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Perl @INC - include NFS mounted repository



On Mon, Sep 18, 2000 at 11:26:02AM +0200, Thomas Gebhardt wrote:
> Hi,
> 
> I'd like to include a NFS mounted repository (actually a very
> comprehensive Debian installation) into the Module Search Path
> of Perl.
> 
> Boundary conditions:
> 
>  * transparent for the users
> 
>  * Modules that are also locally available should not be loaded
>    by NFS.

Hi,

there are several ways of achieving this, although none of them
is without drawbacks:

(1) you can setup the PERL5LIB environment variable (or PERLLIB
    if you want it to apply for both Perl4 and Perl5) to contain
    the appropriate search path for the Modules (a colon-separated
    list of directories)
    If you want local modules to be found first, just put the NFS
    directory at the end of the path list.

This method has the disadvantage that you somehow have to make sure
that PERL5LIB gets set in the environment of the individual users.
This is basically a system administration task. You might consider
one of the following strategies:

* put PERL5LIB in the system-wide login-environment, so users do
  not have to set it themselves
* have users set it by themselves (error-prone)
* write a wrapper script around the call of the perl binary that
  sets the environment
(or whatever else you could think of...)


(2) you can modify the @INC array at the beginning of your perl
    scripts. To have the NFS directory be found last you would
    insert the following code snippet:

    BEGIN { push @INC, "/your-NFS-libpaths-here"; }

    (this gets executed before any "use" or "require" statements,
    so the modified include path applies)
    
    You probably want to include both the normal path (for Perl-only
    modules) and the path for architecture-specific modules
    (containing e.g. something like "i686-linux"), although
    the latter is not always required (just try and see...)

This obviously has the disadvantage that all of your scripts have to
be modified, so depending on how much scripts you have and whether you
could edit them automatically, this approach might not be feasible.


There may be other ways that I'm not aware of, e.g. fiddling around
with symlinks in the ordinary perl lib-dir or changing the compiled-in
lib-path...(?); but as far as I know, this way its not possible to
achieve the kind of "fall-through" behaviour you need.
(if anyone knows how to do this, I'd like to know)

Good luck,
Erdmut


-- 
Erdmut Pfeifer
science+computing gmbh

-- Bugs come in through open windows. Keep Windows shut! --



Reply to: