user402808
user402808

Reputation:

add Perl Modules' Directory to include path using .htaccess for CGI scripts

I've used Cpanel to install per modules on my host server running lightspeed. It gave an "Installation Successful" message too.

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 it's my only access to the server.

Upvotes: 4

Views: 1845

Answers (2)

SAN
SAN

Reputation: 2247

Since you installed these modules manually, i recommend using either use lib or pushing the directory to INC array. Look at this How is Perl's @INC constructed? (aka What are all the ways of affecting where Perl modules are searched for?)

So, you can use either of the below techniques

use lib

use lib /home/username/perl

Modifying 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 add the directory to INC

Upvotes: 2

Martijn
Martijn

Reputation: 1620

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

SetEnv PERL5LIB /home/username/perl

If you want to add more than one path, separate them with :, like this:

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

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

Another option would be adding it to the include path from inside Perl itself. You will have to add the line use lib "/home/username/perl"; to the CGI script(s), somewhere before it loads the module(s) installed there.

Upvotes: 3

Related Questions