Skip to content

Quickstart Guide For Unix

Michael G. Schwern edited this page May 10, 2013 · 9 revisions

Unix includes things like Linux, Mac OS X, Ubuntu, BSD, Fedora, Redhat, etc...

Basically, if it's not Windows, it's Unix.

The tool we rely on to install Perl in your home directory and configure everything is perlbrew. Everything that happens here is happening in your home directory.

Build tools

While most Perl modules are written in Perl, a lot use C and need a C compiler. And most need a utility called "make". Many Unixes come with all that already installed. You can check with make -v and gcc -v.

Here's how to get the C build tools and make on common Unixes.

OS X

OS X does not come with make and a C compiler, you'll have to download either Xcode from the App store or you can get the much smaller "Command Line Tools" from Downloads for Apple Developers.

Ubuntu & Debian

sudo apt-get install build-essential

Fedora & Redhat

sudo yum groupinstall "Development tools"

tl;dr version

Already have Perl?

This will configure your CPAN shells to install into your home directory (so you don't need root), install cpanm (a friendlier CPAN client), and install perl5i.

curl -L https://raw.github.com/schwern/perl5i/master/local-lib-rc > ~/.locallibrc
echo 'source ~/.locallibrc' >> ~/.bashrc
source ~/.locallibrc
curl -L http://cpanmin.us | perl - App::cpanminus
cpanm perl5i

Need Perl?

This will install a new Perl in your home directory (so you don't need root), install cpanm, and install perl5i.

curl -kL http://install.perlbrew.pl | bash
source ~/perl5/perlbrew/etc/bashrc
echo 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.bash_profile
perlbrew install --switch stable
perlbrew install-cpanm
cpanm perl5i
perl -e 'use perl5i::2; say "Hello perl5i!"'

The same thing, but explained

Install perlbrew

Follow the directions on the perlbrew home page. For most folks this should be:

curl -kL http://install.perlbrew.pl | bash

Then make sure its available for use.

source ~/perl5/perlbrew/etc/bashrc

Initialize perlbrew

Run perlbrew init. This will initialize perlbrew and create ~/perl5/perlbrew/.

Then it will tell you to add a line to your ~/.bash_profile. Do that. This line will let perlbrew find perl and configure CPAN.

If you don't have a ~/.bash_profile make one with your favorite text editor or run...

echo 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.bash_profile

Install a recent perl in your home directory

As of this writing, the latest version of perl is 5.16.3. Let's install that.

perlbrew install perl-5.16.3

This will download, build, test and install perl. It will take anywhere from 5 minutes to half an hour depending on how fast your Internet and computer is. Have a sandwich.

Switch to that perl

Tell perlbrew that you want your default perl to be the 5.16.3 you just installed.

perlbrew switch perl-5.16.3

You can check that worked by running perl -v. It should say This is perl 5, version 16, subversion 3 (v5.16.3) built for something-something-something and then a copyright and license.

Install cpanm

cpanm is what we'll be using to install perl5i. perlbrew can take care of installing and configuring it.

perlbrew install-cpanm

You can check that worked by running which cpanm. The result should be something like /home/yourname/perl5/perlbrew/bin/cpanm.

Install perl5i using cpanm

And finally, you can install perl5i!

cpanm perl5i

This will install a lot of modules. It could take a while. Kick back and relax.

Check perl5i is installed

Now you can test that perl5i is installed by running...

perl -e 'use perl5i::2; say "Hello perl5i!"'

And you should see Hello perl5i!.

Congratulations!