What are all the ways of affecting where Perl modules are searched for? or, How is Perl's @INC constructed?
As we know, Perl uses @INC
array containing directory names to determine where to search for Perl module files.
There does not seem to be a comprehensive "@INC" FAQ-type post on StackOverflow, so this question is intended as one.
This question is related to
perl
perl-module
As it was said already @INC is an array and you're free to add anything you want.
My CGI REST script looks like:
#!/usr/bin/perl
use strict;
use warnings;
BEGIN {
push @INC, 'fully_qualified_path_to_module_wiht_our_REST.pm';
}
use Modules::Rest;
gone(@_);
Subroutine gone is exported by Rest.pm.
In addition to the locations listed above, the OS X version of Perl also has two more ways:
The /Library/Perl/x.xx/AppendToPath file. Paths listed in this file are appended to @INC at runtime.
The /Library/Perl/x.xx/PrependToPath file. Paths listed in this file are prepended to @INC at runtime.
Source: Stackoverflow.com