Monthly Archives: December 2007

Perl module in non-standard location

I’ve discovered a module in the CPAN in which i can use Ajax on my CGI script. This module is CGI::Ajax of www.perljax.us.
On my PC, the script I’ve created using the module runs without a problem but then when I upload and execute my script I have this issue:

Can’t locate CGI/Ajax.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/i686-linux /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i686-linux /usr/lib/perl5/site_perl/5.8.8 /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/5.6.2 /usr/lib/perl5/site_perl .) at ./test2.cgi line 15.
BEGIN failed–compilation aborted at ./test2.cgi line 15.

The CGI/Ajax.pm cant be located but then I have already installed that on my server. I realized then that ,since I’m only renting this server, the Perl module is not installed in the standard location.

To solved this, I need to include the code use lib. Lets say I’ve installed the module in /home/pepesmith/modules. ON the first line of my script, before calling the “use CGI::Ajax”, the code that must be inserted is :

use lib "/home/pepesmith/modules";

This means that the directory “/home/pepesmith/modules/” is included in the location of modules stated in @INC as stated here.