How should I install more than one version of Perl

2020-01-30 11:27发布

I want to install, from source, Perl versions 5.005, v5.6, v5.8, v5.10

Right now I have 'v5.10.0' installed.

/opt/perl/bin
/opt/perl/html
/opt/perl/lib
/opt/perl/man
/opt/perl/lib/5.10.0
/opt/perl/lib/site_perl
/opt/perl/lib/site_perl/5.10.0

Will I have any problems if I install them all in /opt/perl?

Or should I split them up into their own, version specific, directories? Like /opt/perl-5.10.0/

6条回答
▲ chillily
2楼-- · 2020-01-30 11:46

Split them into their own version specific directories, and then symlink perl to the version you wish to use at the time. This is how having multiple JREs/JDKs installed works, so it would seem to make sense for Perl installations as well.

查看更多
男人必须洒脱
3楼-- · 2020-01-30 11:57

We develop with multiple versions of Perl here at work, and separate directories is the way to go. We've set up a small shell command that fixes up symlinks and environment variables so you can use the perl you want easily.

If you're worried about forgetting which perl is being used, you could have such a script add a version number to your shell prompt.

查看更多
祖国的老花朵
4楼-- · 2020-01-30 11:58

While installing into different directories is usually a better way to go, you can use the Configure switch -Dversiononly to use a single directory and include the version triplet in all pathnames (except man files, which you'd probably want to avoid installing altogether), giving you for example a perl5.10.0, cpan5.10.0, perldoc5.10.0, etc.

查看更多
Rolldiameter
5楼-- · 2020-01-30 12:06

If you're using CentOS/RHEL servers, you can use the relatively new Software Collection system to install other versions of Perl in addition to the "system Perl" (which is an ancient 5.10 on EL6 and 5.8 on EL5).

There are public repositories for a core set of Perl 5.16 packages:

http://mirror.centos.org/centos/6/SCL/x86_64/

The community is working on publishing a larger subset of CPAN as installable packages and publishing collections for other versions of Perl as well.

查看更多
【Aperson】
6楼-- · 2020-01-30 12:09

I install all of my perls completely in their own directory so they don't share anything with any other perl. To do that, you just tell the Configure script where to install everything. I like /usr/local/perls:

 % ./Configure -des -Dprefix=/usr/local/perls/perl-5.x.y

When I do that for multiple versions, I get a directory that has separate installations.

% ls -1 /usr/local/perls
perl-5.10.0
perl-5.10.1
perl-5.6.2
perl-5.8.8

They all have their own bin and lib directories:

% ls -1 /usr/local/perls/perl-5.10.0
bin
lib
man

Most of the common tools will figure out what to do if you call them with different perls:

/usr/local/perls/perl-5.10.0/bin/perl /usr/local/bin/cpan

However, you can take the perl you want to use the most and put it first in your path. I just make a symlink to /usr/local/bin/perl, but you can add directories to PATH as well.

The perlbrew does a lot of this for you and moves symlinks around to make one of them the default perl. I don't use it though because it doesn't make life easier for me. That's up to you decide on your own though.

查看更多
走好不送
7楼-- · 2020-01-30 12:09

You really should install the different versions into distinct directories.

When I want to try multiple versions of a package that doesn't exist as packages for my favorite Linux distribution, I use stow or xstow as a poor man's package manager:

  • Create a directory /usr/local/stow
  • Install individual packages into /usr/local/stow/$PACKAGE-$VERSION
  • map a "package" into /usr/local: stow -d /usr/local/stow $PACKAGE-$VERSION
  • deactivate a "package": stow -d /usr/local/stow -D $PACKAGE-$VERSION

stow does its work by creating and manipulating symlinks and it is able to detect conflicts.

查看更多
登录 后发表回答