Take the 2-minute tour ×

I need to install some Perl Modules for my Perl scripts. However those modules are not available on the servers I want to run the scripts on. I also do not want to mess with server wide library directories. I think it can be done by manipulating the "@INC" variable. I need to know how to install the new modules using cpan and the alternate @INC.

Alternatively, it might also make sense to bundle my own Perl binary/environment with my script. Any ideas?

share|improve this question

2 Answers 2

Long answer can be found here: http://www.devdaily.com/perl/edu/articles/pl010015

Short answer, put your modules to, say, /home/face429/perlmodules, then in your perl program use: use lib '/home/face429/perlmodules';.

To check whether that path has been included to @INC usage you can print the @INC.

share|improve this answer
Thanks Favoretti, and how can I use CPAN to place those modules there? Keeping in mind, firewalls are not allowing the connection from the server to the internet (I tried CPAN ftp and http). I manaed to use my desktop to get those modules, I want to know where I can transfer them to the server (i.e do I just scp the directory to anywhere ?) –  Face429 Jan 30 '12 at 14:52

Your current directory is part of the path searched by Perl.

perl -V will show you the content of @INC, which includes "." (the current directory) at the end.

Note that your current directory is exactly that, not the directory where your script is. If this is to run on a web server, it will break easily.

You can also add a specific path by putting use lib '/your/perl/modules' into your script, as explained by favoretti.

Finally, you can add a path for all your scripts through the environment variable PERLLIB, so you don't have to use libin every script.


or SET PERLLIB = C:/your/perl/modules in Windows.

share|improve this answer

Your Answer


