Background
If you’re a Ruby or Ruby on Rails developer then you’re most likely familiar with rvm. rvm is just one of those tools that once you get your head around and start to use, you’ll say “duh! Why didn’t I think of this earlier?”. Well I just found a similar tool for Perl. It’s called Perlbrew (App::perlbrew), and it works very similarly to rvm.
Now in case you’re not familiar with rvm, perlbrew allows you to manage multiple perl installations in your $HOME directory. Having this capability is huge. For example:
- No need to run sudo to install CPAN modules, any more.
- Try the monthly released new perls.
- Learn new language features.
- Test production code.
- Leave vendor perl (the one that comes with OS) alone
- Maintain completely isolated perl universes.
Solution
The installation is pretty much in line with rvm’s, mainly:
1
2
3
4
5
6
7
8
| # via curl
% curl -kL http://install.perlbrew.pl | bash
# via wget
% wget --no-check-certificate -O - http://install.perlbrew.pl | bash
# via cpan
% sudo cpan App::perlbrew |
Now you’re ready to initialize your installation area.
1
2
| # Initialize
% perlbrew init |
And here are some of the basic things you can do to manage your $HOME perl installations.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
| # Pick a preferred CPAN mirror
% perlbrew mirror
# See what is available
% perlbrew available
# See full help
% perlbrew help
# Install some Perls
% perlbrew install 5.14.0
% perlbrew install perl-5.8.1
% perlbrew install perl-5.13.6
# See what were installed
% perlbrew list
# Switch perl in the $PATH
% perlbrew switch perl-5.12.2
% perl -v
# Temporarily use another version only in current shell.
% perlbrew use perl-5.8.1
% perl -v
# Or turn it off completely. Useful when you messed up too deep.
# Or want to go back to the system Perl.
% perlbrew off
# Use 'switch' command to turn it back on.
% perlbrew switch perl-5.12.2
# Exec something with all perlbrew-ed perls
% perlbrew exec perl -E 'say $]'
# Exec you program using all the perlbrew-ed perls
% perlbrew exec myprogram.pl |
The primary command, perlbrew has the general form:
…. Continue reading → [one-liner]: Managing Multiple Installations of Perl in your $HOME Directory using Perlbrew »»