If mod_perl encounters a statement like the following:
use lib qw(foo/bar);
it modifies @INC only for the period during which the code is being parsed and compiled. Afterward, @INC is reset to its original value. Therefore, the only way to change @INC permanently is to modify it at server startup.
In the configuration file, with:
PerlSetEnv PERL5LIB /home/httpd/perl
PerlSetEnv PERL5LIB /home/httpd/perl:/home/httpd/mymodules
use lib qw(/home/httpd/perl /home/httpd/mymodules); 1;
As always, the startup file needs to be loaded from httpd.conf:
To make sure that you have set @INC correctly, configure perl-status into your server, as explained in Chapter 21. Follow the "Loaded Modules" item in the menu and look at the bottom of the generated page, where the contents of @INC are shown:
@INC = /home/httpd/mymodules /home/httpd/perl /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl . /home/httpd/httpd_perl/ /home/httpd/httpd_perl/lib/perl
As you can see in our setup, we have two custom directories prepended at the beginning of the list. The rest of the list contains standard directories from the Perl distribution, plus the $ServerRoot and $ServerRoot/lib/perl directories appended at the end (which mod_perl adds automatically).