Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Maintaining several perl versions on the same box

by est (Acolyte)
on Sep 17, 2008 at 05:28 UTC ( #711873=perlquestion: print w/replies, xml ) Need Help??
est has asked for the wisdom of the Perl Monks concerning the following question:

I've been long looking for a (easy) way of maintaining several perl versions on the same box without having to modify any single old programs rely on the old perl.

This article Best Pratices for Keeping Your Perl Installation Sane describes the good ways to do it, but not how...

E.g. if I want to keep my old 5.8.8 and try 5.10 and my all old programs have the shebangs line sets to "/usr/bin/perl" - so if I install 5.10 in "/usr/local/perl/*" I presume it will also modify /usr/bin/perl into the new version?
If so, how to avoid it?

Also, what is the best way to quickly switch back and forth between those perl versions (inccluding the CPAN modules installed)? I might still need to code in 5.8.8 for the reason to sync with our production server, etc.

Any experiences?
  • Comment on Maintaining several perl versions on the same box

Replies are listed 'Best First'.
Re: Maintaining several perl versions on the same box
by Erez (Priest) on Sep 17, 2008 at 07:25 UTC

    OTTOMH, two ways:
    One: call the actual perl binary, i.e. %/usr/local/perl
    Two: temporarily reorder the $PATH variable in your shell, i.e.

    %echo $PATH /usr/bin/:/usr/local/bin
    (perl is system 5.8.8 perl)
    %PATH=/usr/local/bin/:/usr/bin %echo $PATH /usr/local/bin/:/usr/bin
    (perl is local 5.10 perl, as the shell looks for "perl" according to the order of folders in $PATH).
    Actual syntax may varies with your flavour of *NIX/shell.

    Stop saying 'script'. Stop saying 'line-noise'.
    We have nothing to lose but our metaphors.

Re: Maintaining several perl versions on the same box
by bingos (Vicar) on Sep 17, 2008 at 11:00 UTC

    Further to Erez's comments above regarding changing the PATH, you can change the shebang line in scripts to the following:

    #!/usr/bin/env perl

    This will setup the shebang correctly in your scripts depending on which perl executable is found in the PATH

    Small test on a NetBSD system:

    [canker:~]$ ls -l -rwxr-xr-x 1 chris users 35 Sep 17 11:52 [canker:~]$ cat #!/usr/bin/env perl print "$]\n"; [canker:~]$

    With normal system PATH:

    [canker:~]$ ./ 5.008008 [canker:~]$

    Which an amended PATH:

    [canker:~]$ PATH=/opt/perl-5.10.0/bin:$PATH ./ 5.010000 [canker:~]$

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://711873]
Approved by lamp
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-10-19 23:12 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (258 votes). Check out past polls.