Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

Long answer can be found here:

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


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.