[sf-perl] /usr/local/foo/ for cpan and locally grown modules

David Alban extasia at extasia.org
Mon Jan 29 18:01:50 PST 2007

(Assume I'm not allowed to update the "live" perl installation, so I'm
installing modules in the /usr/local/reg tree.)  I have:

$ find /usr/local/reg/lib/perl5 -type f

Crypt::PasswdMD5 is from CPAN.  I took Garth's suggestion and did:

  $ perl Makefile.PL PREFIX=/usr/local/reg

and the files were installed as shown above.  Log::Transcript is the
module I wrote.

Ideally, I'd like to have users be able to include a single "use ..."
statement in the code.[1]  I'd like it to be:

  use lib "/usr/local/reg/lib/perl5";
        # or /usr/local/reg/lib/perl if I make the latter a symlink to
the former

Not two:

  use lib "/usr/local/reg/lib/perl5";
  use lib "/usr/local/reg/lib/perl5/site_perl";

Based on Quinn's suggestion, I thought the former might allow a
program to pick up both Log::Transcript (or, home-grown modules) and
Crypt::PasswdMD5 (or, cpan installed modules).  But it doesn't pick up
the site_perl tree:

$ unset PERL5LIB; perl -I/usr/local/reg/lib/perl5 -MCrypt::PasswdMD5 -e 1
Can't locate Crypt/PasswdMD5.pm in @INC (@INC contains:
/usr/local/reg/lib/perl5/5.8.0 /usr/local/reg/lib/perl5
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0 .).
BEGIN failed--compilation aborted.

It's a little clearer here:

$ unset PERL5LIB; perl -I/usr/local/reg/lib/perl5 -e 'print join "\n", @INC'

Am I missing something that I can use to get a single:

  use lib "/usr/local/reg/lib/perl5";

statement to work (i.e., to include the site_perl tree, too)?


[1] There's no hope of getting them to set PERL5LIB in their environment

On 1/25/07, Quinn Weaver <quinn at fairpath.com> wrote:
> Right.  And in this case, you'd do
> export PERL5LIB=/usr/local/reg/lib/perl5 # bash syntax
> ... then Perl automatically searches under there for site_perl,
> site_perl/5.8.0, and all those other weirdly named subdirs that
> Perl uses to install things.

Live in a world of your own, but always welcome visitors.

More information about the SanFrancisco-pm mailing list