We will look at how the contents of this array are constructed and can be manipulated to affect where the Perl interpreter will find the module files.

Default @INC Perl interpreter is compiled with a specific @INC default value. To find out this value, run env -i perl -V command ( env -i ignores the PERL5LIB environmental variable - see #2) and in the output you will see something like this: $ env -i perl -V ... @INC: /usr/lib/perl5/site_perl/5.18.0/x86_64-linux-thread-multi-ld /usr/lib/perl5/site_perl/5.18.0 /usr/lib/perl5/5.18.0/x86_64-linux-thread-multi-ld /usr/lib/perl5/5.18.0 .

Note . at the end; this is the current directory (which is not necessarily the same as the script's directory). It is missing in Perl 5.26+, and when Perl runs with -T (taint checks enabled).

To change the default path when configuring Perl binary compilation, set the configuration option otherlibdirs :

Configure -Dotherlibdirs=/usr/lib/perl5/site_perl/5.16.3

Environmental variable PERL5LIB (or PERLLIB ) Perl pre-pends @INC with a list of directories (colon-separated) contained in PERL5LIB (if it is not defined, PERLLIB is used) environment variable of your shell. To see the contents of @INC after PERL5LIB and PERLLIB environment variables have taken effect, run perl -V . $ perl -V ... %ENV: PERL5LIB="/home/myuser/test" @INC: /home/myuser/test /usr/lib/perl5/site_perl/5.18.0/x86_64-linux-thread-multi-ld /usr/lib/perl5/site_perl/5.18.0 /usr/lib/perl5/5.18.0/x86_64-linux-thread-multi-ld /usr/lib/perl5/5.18.0 . -I command-line option Perl pre-pends @INC with a list of directories (colon-separated) passed as value of the -I command-line option. This can be done in three ways, as usual with Perl options: Pass it on command line: perl -I /my/moduledir your_script.pl

Pass it via the first line (shebang) of your Perl script: #!/usr/local/bin/perl -w -I /my/moduledir

Pass it as part of PERL5OPT (or PERLOPT ) environment variable (see chapter 19.02 in Programming Perl) Pass it via the lib pragma Perl pre-pends @INC with a list of directories passed in to it via use lib . In a program: use lib ("/dir1", "/dir2"); On the command line: perl -Mlib=/dir1,/dir2 You can also remove the directories from @INC via no lib . You can directly manipulate @INC as a regular Perl array. Note: Since @INC is used during the compilation phase, this must be done inside of a BEGIN {} block, which precedes the use MyModule statement. Add directories to the beginning via unshift @INC, $dir .

Add directories to the end via push @INC, $dir .

Do anything else you can do with a Perl array.

Note: The directories are unshifted onto @INC in the order listed in this answer, e.g. default @INC is last in the list, preceded by PERL5LIB , preceded by -I , preceded by use lib and direct @INC manipulation, the latter two mixed in whichever order they are in Perl code.

References:

There does not seem to be a comprehensive @INC FAQ-type post on Stack Overflow, so this question is intended as one.

When to use each approach?