18

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/

Ether
  • 53,118
  • 13
  • 86
  • 159
Brad Gilbert
  • 33,846
  • 11
  • 78
  • 129
  • 2
    You should also take a look at this: http://stackoverflow.com/questions/398221/how-do-you-manage-perl-modules-on-linux – innaM Aug 17 '09 at 18:48
  • 2
    these days the easiest way to deal with multiple versions of perl is probably `perlbrew` https://metacpan.org/module/perlbrew – mirod Nov 15 '12 at 11:20

6 Answers6

15

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.

brian d foy
  • 129,424
  • 31
  • 207
  • 592
  • `/usr/local/perls/bin` could be a good place to put symlinks to the version specific Perls. Then I would only need to add that to `PATH`. – Brad Gilbert Aug 18 '09 at 01:03
  • 1
    -1 :: It would be more helpful to also mention how to use cpan with multiple installation of Perl. – Ωmega Apr 17 '12 at 15:02
  • 2
    Just call the `cpan` script in the appropriate bin directory just like you'd call the different `perl` programs. – brian d foy Apr 17 '12 at 15:08
  • This is how I have been managing this. Except using `/opt/perl-5.16.0`. With alias of `/opt/perl/bin/perl-5.16.0` to `/opt/perl-5.16.0/bin/perl`, along with other aliases. – Brad Gilbert Jul 10 '12 at 22:00
  • is this answer still correct? With 5.28 I get `/usr/local/bin is not writable by you` (using a prefix which is writable by me and totally outside of /usr/local/bin) – Oh My Goodness Feb 20 '19 at 01:45
  • @OhMyGoodness it's still correct, but you need to have write permission to wherever you want to install it. That's always been true. I use a 'perl' group, add myself to that group, and make those directories owned and writable by that 'perl' group. – brian d foy Feb 20 '19 at 03:02
  • @briandfoy I do have permission; I don't want to install to /usr/local/bin; `./Configure -des -Dprefix=/foo` yields `/usr/local/bin is not writable by you` when `make install` is invoked. – Oh My Goodness Feb 20 '19 at 06:05
  • @OhMyGoodness perhaps you should ask a formal StackOverflow question. – brian d foy Feb 20 '19 at 12:16
7

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.

Sinan Ünür
  • 116,958
  • 15
  • 196
  • 339
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406
2

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.

hillu
  • 9,423
  • 4
  • 26
  • 30
  • 1
    More information on GNU Stow is available at [the Stow home page](http://www.gnu.org/software/stow/). I am actively maintaining it. – Adam Spiers Apr 14 '13 at 15:33
2

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.

fozzmoo
  • 21
  • 1
0

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.

Brad Gilbert
  • 33,846
  • 11
  • 78
  • 129
Chris Simmons
  • 1,843
  • 1
  • 12
  • 18
0

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.

Brad Gilbert
  • 33,846
  • 11
  • 78
  • 129
ysth
  • 96,171
  • 6
  • 121
  • 214