Adding Perl modules to the include path

peterr

Well-Known Member
Sep 24, 2003
85
0
156
cPanel Version 11.4.19-RELEASE
cPanel Build 14379

There is a Perl module I wanted to use, it wasn't installed on the system, so I went to install it. It installed okay via CPanel, but when I ran a Perl script, there was a message about the @INC variable (include path).

I then added the code shown in CPanel ...

Using Your Perl Module(s)

You will need to add /home/username/perl to the include path.
You can do this by adding the following code to your script:

and ran the script again. The 'include' seemed to work, in that now there are quite a few more paths in the error message from the perl script ..

Can't locate Net/Abuse/Utils.pm in @INC (@INC contains: /usr/lib/perl5/5.8.7/i686-linux /usr/lib/perl5/5.8.7 /usr/lib/perl5/site_perl/5.8.7/i686-linux /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl .) at scriptname.pl line 21.
The Perl module "utils.pm" is in /home/username/perl/usr/lib/perl5/site_perl/5.8.7/Net/Abuse/

Does the Perl code shown in CPanel (at https://example.com/frontend/x3/module_installers/index.html?lang=perl ) work correctly ? There are a lot of other paths that have been added to the @INC variable though, so it would seem it works.

Just that the path where the module is hasn't been included. :confused:
 

peterr

Well-Known Member
Sep 24, 2003
85
0
156
I know this is off-topic, but are you sure you are running Perl 5.8.8? I know some people have encountered issues while running 5.8.7 with cPanel 11.
Hmm, it seems not, a script just showed ..

This is perl, v5.8.7 built for i686-linux Copyright 1987-2005, Larry Wall
For instructions on how to check and how to upgrade, check out this thread: http://forums.cpanel.net/showthread.php?t=66166
Thanks, I will have to get my hosting provider to upgrade to perl 5.8.8
 

Miraenda

Well-Known Member
Jul 28, 2004
243
5
168
Coralville, Iowa USA
cPanel Access Level
Root Administrator
If you go to your cPanel account > Perl Modules area, you will see the code indicated on the page:

Code:
You will need to add /home/username/perl to the include path.
You can do this by adding the following code to your script:

BEGIN {
    my $base_module_dir = (-d '/home/username/perl' ? '/home/username/perl' : ( getpwuid($>) )[7] . '/perl/');
    unshift @INC, map { $base_module_dir . $_ } @INC;
}
This is the code that is noted there (where username will be your cPanel username). It isn't added into the module but into your script that is using the module.
 
Last edited: