Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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
Re: Maintaining several perl versions on the same box
by Erez (Curate) on Sep 17, 2008 at 07:25 UTC

    OTTOMH, two ways:
    One: call the actual perl binary, i.e. %/usr/local/perl myprogram.pl
    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 test.pl -rwxr-xr-x 1 chris users 35 Sep 17 11:52 test.pl [canker:~]$ cat test.pl #!/usr/bin/env perl print "$]\n"; [canker:~]$

    With normal system PATH:

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

    Which an amended PATH:

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://711873]
Approved by lamp
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2014-12-29 16:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (193 votes), past polls