zakzebrowski has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, I would like to have cpan modules installed into multiple directories on a single computer, as shown in the following example:

Is there an elegent way to do this? I know that for a single custom directory (eg. /app/common/cpan ), I could do something like: perl Makefile.PL PREFIX=/app/common/cpan LIB=/app/common/cpan , and then just use lib '/app/common/cpan' in my applications, but I tried doing a perl Makefile.PL PREFIX=/app/subapp/cpan:/app/common/cpan but that didn't work. Any ideas, or am I making this too hard on myself?

Zak - the office

Replies are listed 'Best First'.
Re[0]: Multiple Library Includes
by Intrepid (Deacon) on Jun 30, 2004 at 17:27 UTC
    Hi All, I would like to have cpan modules installed into multiple directories on a single computer, as shown in the following example:

    1. /usr/local/lib - Only perl base modules
    2. /app/common/cpan - Common but not core base modules (EG. DBI,Date::Manip)
    3. /app/subapp/cpan - Not common cpan libraries (EG. If I was a supermarket store, I may include for a specific sub application a bar code module if the code I wrote involved inventory etc, and a different department (say finance) would include various accountine modules)
    Is there an elegent way to do this?

    Yep ... compile perl yourself, with these as your build-time config params. You asked for elegant. This is the only elegant way. All other ways that might be devised are only express trains on the bad line headed straight for Kludgeville.

    In particular, the vendor* dirs seem correctly suited to this notion you have of placing modules belonging to specific applications in a separate directory hierarchy of their own.

    Related sufficiently to this question that I dare mention it, I've got a tool that I wrote for people with issues like this in mind: showPerlDirConfig. This will show you what your currently-running perl knows internally as its Config dirs. Looking at the output for a just a minute is likely to bring about better understanding for you than quite lengthy attempts at verbal explanations would accomplish.

    After running that utility of mine, reading the POD-format file INSTALL that is found in the toplevel of every Perl source kit (every release), would give you some insights, I think.

        Soren A / somian / perlspinr / Intrepid

    Now, 2004: The 3 least meaningful terms in online jargon are:
    troll flame rant
    These used to mean something; but then they were highjacked by the kind of inferior intellects who, when faced with a more erudite opponent employing superior arguments (or simply hanging in there stolidly with a disagreeable contention), abuse these terms -- merely another form of low-life name-calling. ;-)
Re: Multiple Library Includes
by hawtin (Prior) on Jul 01, 2004 at 08:42 UTC

    I think that setting $PERL5LIB will do what you want, add the following to your profile (.login/ .tcshrc or whatever):

    setenv PERL5LIB /usr/local/lib:/app/common/cpan:/app/subapp/cpan

    Alternately you can pass -I flags (for example by editing the shebang line in your scripts).

    And finally you can modify @INC in the scripts before calling require:

    push(@INC,"/app/subapp/cpan"); require Module97;

    If you can recompile and reinstall Perl that solution is a good idea, but if not there is more than one way to do it.