Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

BooK (2612)

BooK
  {book} {at} {cpan.org}
http://paris.mongueurs.net/
Yahoo! ID: philippe_bruhat (Add User, Send Message)

Obfuscation [plover.com]. Pink [axis-of-aevil.net]. HTTP::Proxy [cpan.org]. YEF [yapceurope.org]. Fishnet [perl.org]. Kapow [cpan.org]. Cog's [perl.org] bitch [cpan.org]. Invitation [perl.org]. White [perl.org] Camel [perl.org]. Nuff' said.

Journal of BooK (2612)

Thursday October 22, 2009
03:13 AM

Switching perls

[ #39786 ]

I have a few perls compiled and installed in /opt/perl:

$ ls /opt/perl
5.10.0  5.6.2  5.8.7  5.8.8

A long time ago, I tried to set up an environment that would setup the proper PATH to always reach the perl I wanted when typing perl on the command-line. That involved a shell script, which of course couldn't change the environment of the outer shell, so it actually started another shell, resulting in the following mess:

5271 pts/2    Ss     0:01 bash
6182 pts/2    S      0:00  \_ /bin/bash ./perlenv 5.10.0
6183 pts/2    S      0:00      \_ /bin/bash

I could also have moved a canonical symlink around, but this had the advantage that several independent shells could run different perls.

Anyway, that was unworkable until I realized I could change the current shell environment using aliases or shell functions. So, assuming my perl binaries live in /opt/perl/$VERSION/bin, the following bash shell function does the trick:

setperl ()
{
    export PATH=`echo $PATH|sed -e "s:/opt/perl/[^/]*/bin:/opt/perl/$1/bin:"`
}

And my ~/.bashrc points to the perl I want to use by default.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.