Add Perl Modules' directory to include the path using .htaccess for CGI scripts

I used Cpanel to install on modules on my backlit host server. He also gave the message "Installation Successful."

But it shows:

Location of your Perl module (s) Path: / home / username / perl

Using your Perl module (s): You will need to add / home / username / perl to the include path.

Is it possible to add it using only .htaccess? Because this is my only access to the server.

+4
source share
2 answers

This should be possible using the SetEnv directive. Try putting this in your .htaccess:

SetEnv PERL5LIB /home/username/perl 

If you want to add several paths, divide them into : for example:

 SetEnv PERL5LIB /home/username/perl:/some/other/path 

You can (of course) also use this to set other environment variables.

Another option is to add it to the include path from Perl itself. You will need to add the line use lib "/home/username/perl"; in the CGI script (s), somewhere, before loading the modules (modules) installed there.

+3
source

Since you installed these modules manually, I recommend using either use lib or redirecting the directory to an INC array. Look at it. How is Perl's @INC building built? (aka What are some ways to influence the search for Perl modules?)

So you can use any of the following methods

use lib

 use lib /home/username/perl 

Modifying an INC Array

To add directories to the beginning

 unshift @INC, /home/username/perl 

To add directories to the end

 push @INC, /home/username/perl 

I also recommend moving the modules to a directory relative to your cgi-bin and using FindBin and adding the directory to INC

+2
source

Source: https://habr.com/ru/post/1380972/


All Articles