I'm using perlbrew right now to manage multiple versions of perl, but perlbrew is global. If I do perlbrew switch perl-5.10.1
in any shell, then all shells and scripts will now be using perl version 5.10.1. There is no isolation. Is there any way to make perlbrew switches local to a shell, or is there a similar tool capable of locally changing the active perl?
Asked
Active
Viewed 548 times
5

Ryan C. Thompson
- 40,856
- 28
- 97
- 159
-
See also [How should I install more than one version of Perl?](http://stackoverflow.com/questions/1289564/how-should-i-install-more-than-one-version-of-perl) and [http://stackoverflow.com/questions/398221/how-do-you-manage-perl-modules-when-using-a-package-manager/398397#398397](How do you manage Perl modules when using a package manager?) – Ether Oct 09 '10 at 00:55
-
See this related SO question/answer: http://stackoverflow.com/questions/3776390/how-can-i-control-the-perl-version-used-when-submitting-grid-jobs/3776538#3776538 – draegtun Oct 09 '10 at 09:35
2 Answers
5
Just don't use perlbrew. All it's doing is changing symlinks for you. It's supposed to save you work, but when it's not, there's no longer a reason to use it.
I talk about how I do it in Make links to per-version tools in The Effective Perler. I always know which perl I'm using because I never have to remember which one I switched to last, and I don't disturb anything else expecting a particular version behind a symlink. You can still use perlbrew to install perls, but it's not saving you that much work there either.

brian d foy
- 129,424
- 31
- 207
- 592
-
[Also discussed here](http://stackoverflow.com/questions/398221/how-do-you-manage-perl-modules-when-using-a-package-manager/398397#398397) in more detail. – Ether Oct 08 '10 at 23:30
-
1I know I can always install perl 5.10.1 as `perl5.10.1` in my path and then specify versions explicitly, but I guess that the behavior that I'm looking for is that `perl` runs a certain default version of perl. Then if I run `perlbrew switch` in one shell, then `perl` in that shell refers to the new version, but all other shells and programs continue to run the default perl. And ditto for the rest of the perl environment: modules, executables, manpages/perldocs. I suppose I'll have to learn how to use the Furlani Modules package that your article links to in order to get what I want. – Ryan C. Thompson Oct 09 '10 at 01:05
-
Actually it probably wouldn't be hard to give perlbrew the option to only affect a local shell environment -- since it already writes bashrc/cshrc files that means it can install shell aliases/functions. Write one that modifies PATH instead of switching symlinks and you're golden. I might give it a try. – hobbs Oct 09 '10 at 01:55
-
Doing perlbrew with environment variables is more complicated than just messing with PATH, though. You would also have to change a few other environment variables (e.g. MANPATH to get correct documentation when you do `man Some::Module`). – Ryan C. Thompson Oct 09 '10 at 02:19
-
@Ryan perlbrew doesn't do anything about those things now -- `man` doesn't find anything inside a perlbrew, for instance. All it does is put a directory into `PATH` and symlink things into that directory. – hobbs Oct 09 '10 at 05:31
-
4
In more recent versions of Perlbrew, you can do perlbrew use perl-5.12.3
or whatever and you'll be using that version of Perl, but only in the current shell session. Other sessions won't be affected.

Piers Cawley
- 686
- 6
- 13
-
I'll have to try this out. It looks like exactly what I want. – Ryan C. Thompson Feb 18 '11 at 20:22