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

Hi,

I use the PERL5LIB environment variable to specify additional module directories to search (and I gave my reasons here).

My problem is that now I am starting to play with perl 5.6.0, so a lot of my existing modules need to be recompiled. Since the standard installation procedure creates version-specific directories under the PREFIX you specify, I thought it would be a simple matter of installing the new 5.6.0 modules under the same hierarchy and perl would find them automatically depending on which version I was running.

Wrong. See, my PERL5LIB variable used to contain:

/p/perl/lib:/p/perl/lib/site_perl/5.005:/p/perl/lib/site_perl/5.005/su +n4-solaris: /p/perl/lib/sun4-solaris
Where "/p/perl" is my directory for "local modules, installed without root privileges".

When I install some modules with 5.6.0, using the same PREFIX of "/p/perl", it correctly creates /p/perl/lib/site_perl/5.6.0, etc. However, my PERL5LIB does not work, because it explicitly mentions the 5.005 directories. I tried shortening it to:

/p/perl/lib:/p/perl/lib/site_perl:/p/perl/lib/sun4-solaris
Hoping that perl would automatically search the version- and architecture-specific directories, but it does not work. It doesn't find a lot of my modules.

From the perlrun man page:

PERL5LIB    A colon-separated list of directories in which
            to look for Perl library files before looking in
            the standard library and the current directory.
            Any architecture-specific directories under the
            specified locations are automatically included
            if they exist.
But it doesn't mention anything about version-specific directories.

Any ideas? What I would like to do is able to run both versions of perl (5.005 and 5.6.0) with the same PERL5LIB settings, and have it automatically search the correct directories. I do not want to have to include "use lib" statements in my scripts (part of what I am doing is precisely checking whether any of my existing scripts break under 5.6.0).

Thanks a lot!
--Diego

Replies are listed 'Best First'.
RE: How to automatically search version- and architecture-specific module directories
by Anonymous Monk on May 08, 2000 at 22:51 UTC
    this is a job for perl :) make a entry in /bin call Perl. this assumes that you have symbolic links to /bin/perl that point to the version your testing. #!/usr/bin/perl #/usr/bin/Perl if ($] > 5.005) { $ENV{'PERL5LIB'} =~ s/^/\/p\/perl\/lib\/site_perl\/5.6:/; } exec '/usr/bin/perl' , @ARVG;
      I guess this would work. Sigh... I was hoping for something built-in, some more intelligent behavior, coming from Perl... :-(

      Any other ideas?

      Thanks,

      --ZZamboni