I had this problem when installing modules locally also. I wrote a small 'helper' module that I include from the command line, or in my scripts, which customises @INC for me by reading in a config file that contains a list of all directories I want added.

The module looks for a file /etc/perl5lib.pm (or %windir%/perl5lib.pm) and reads in a array ref of directories from that file.

It then massages @INC to include all relevant directories under those paths using hints from Config.pm about sitelib/privlib/archlib/vendorlib etc. without them needing to be explicitly declared.

You can download the file from here - it is too hackish to upload to CPAN as a module.

The /etc/perl5lib.pm file is in Data::Dumper format - it looks like this:

$VAR1=[ '/opt/project1', '/opt/project2', .. ];

Then to include all the above directories *and* any relevant vendorlib/sitelib/archlib etc directories under them in which modules may have been installed, run

perl -I/path/to/perl5lib.pm -Mperl5lib script.pl

Or include in your script:

#!/bin/perl use lib '/path/to/perl5lib.pm', use perl5lib

I did not know about the perl Makefile.PL PREFIX=<path> LIB=<path> option mentioned above though - that looks like a better idea if the modules are not already installed.


In reply to Re: Installing modules locally by aspeer
in thread Installing modules locally by szabgab

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.