Perl modules are generally placed in four main directories. To find these directories, execute:
panic% perl -V
The output contains important information about your Perl installation. At the end you will see:
Characteristics of this binary (from libperl): Built under linux Compiled at Oct 14 2001 17:59:15 @INC: /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 .
This shows us the content of the Perl special variable @INC, which is used by Perl to look for its modules. It is equivalent to the PATH environment variable, used to find executable programs in Unix shells.
Notice that Perl looks for modules in the . directory too, which stands for the current directory. It's the last entry in the above output.
This example is from Perl Version 5.6.1, installed on our x86 architecture PC running Linux. That's why you see i386-linux and 5.6.1. If your system runs a different version of Perl, or a different operating system, processor, or chipset architecture, then some of the directories will have different names.
All the platform-specific files (such as compiled C files glued to Perl with XS, or some .h header files) are supposed to go into the i386-linux-like directories. Pure Perl modules are stored in the non-platform-specific directories.
As mentioned earlier, you find the exact directories used by your version of Perl by executing perl -V and replacing the global Perl installation's base directory with your home directory. Assuming that we use Perl 5.6.1, in our example the directories are:
/home/stas/lib/perl5/5.6.1/i386-linux /home/stas/lib/perl5/5.6.1 /home/stas/lib/perl5/site_perl/5.6.1/i386-linux /home/stas/lib/perl5/site_perl/5.6.1 /home/stas/lib/perl5/site_perl
There are two ways to tell Perl about the new directories: you can either modify the @INC variable in your scripts or set the PERL5LIB environment variable.