Slash Boxes
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} {at} {}
Yahoo! ID: philippe_bruhat (Add User, Send Message)

Obfuscation []. Pink []. HTTP::Proxy []. YEF []. Fishnet []. Kapow []. Cog's [] bitch []. Invitation []. White [] Camel []. 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.
More | Login | Reply
Loading... please wait.