ServersInstallation of mod_perl-enabled Apache Without Superuser Privileges Page 3

Installation of mod_perl-enabled Apache Without Superuser Privileges Page 3




Another way is to write code to modify @INC explicitly:

  BEGIN {
    unshift @INC,
      qw(/home/stas/lib/perl5/5.00503
         /home/stas/lib/perl5/5.00503/i386-linux
         /home/stas/lib/perl5/site_perl/5.005
         /home/stas/lib/perl5/site_perl/5.005/i386-linux);
        }

Note that with the lib module we don’t have to list the
corresponding architecture specific directories, since it adds them
automatically if they exist (to be exact, when //auto
exists).

Also, notice that both approaches prepend the directories to be
searched to @INC. This allows you to install a more recent module
into your local repository and Perl will use it instead of the older one
installed in the main system repository.

Both approaches modify the value of @INC at compilation time.
The lib module uses the BEGIN block as well, but
internally.

Now, let’s assume the following scenario. I have installed the
LWP package in my local repository. Now I want to install another
module (e.g. mod_perl) and it has LWP listed in its prerequisites
list. I know that I have LWP installed, but when I run perl
Makefile.PL
for the module I’m about to install I’m told that I don’t
have LWP installed.

There is no way for Perl to know that we have some locally installed
modules. All it does is search the directories listed in @INC, and
since the latter contains only the default four directories (plus the
. directory), it cannot find the locally installed
LWP package. We cannot solve this problem by adding code to modify
@INC, but changing the PERL5LIB environment variable
will do the trick. If you are using t?csh for interactive work, do
this:

  setenv PERL5LIB /home/stas/lib/perl5/5.00503:
  /home/stas/lib/perl5/site_perl/5.005

It should be a single line with directories separated by colons
(:) and no spaces. If you are a (ba)?sh user, do
this:

  export PERL5LIB=/home/stas/lib/perl5/5.00503:
  /home/stas/lib/perl5/site_perl/5.005

Again, make it a single line. If you use bash you can use multi-line
commands by terminating split lines with a backslash (), like
this:

  export PERL5LIB=/home/stas/lib/perl5/5.00503:  /home/stas/lib/perl5/site_perl/5.005

As with use lib, perl automatically prepends the architecture
specific directories to @INC if those exist.

When you have done this, verify the value of the newly configured
@INC by executing perl -V as before. You should see
the modified value of @INC:

  % perl -V
  
  Characteristics of this binary (from libperl): 
  Built under linux
  Compiled at Apr  6 1999 23:34:07
  %ENV:
    PERL5LIB="/home/stas/lib/perl5/5.00503:
    /home/stas/lib/perl5/site_perl/5.005"
  @INC:
    /home/stas/lib/perl5/5.00503/i386-linux
    /home/stas/lib/perl5/5.00503
    /home/stas/lib/perl5/site_perl/5.005/i386-linux
    /home/stas/lib/perl5/site_perl/5.005
    /usr/lib/perl5/5.00503/i386-linux
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i386-linux
    /usr/lib/perl5/site_perl/5.005
    .

When everything works as you want it to, add these commands to your
.tcshrc or .bashrc file. The next time you start a
shell, the environment will be ready for you to work with the new Perl.

Latest Posts

Related Stories