Modern Perl Development Environment

January 12 2014

If you've ever had to deal with delays in getting CPAN modules installed on a dev server, or simply had issues with a new server build and can't get CPAN running at all, then it may be time to look into running a modern Perl development environment, enabling you to run a local development environment, with no outside hassle.

Modern Perl Development Environment

The first step in building a Perl dev environment is to install perlbrew.  A simple script that creates a ~/perl5/perlbrew/ directory structure for you, to contain builds of individual Perl binaries, and all the CPAN modules you install when using a particular build.

Perlbrew can be installed via cpan, or you can download it directly...

$ curl -kL | bash


$ wget --no-check-certificate -O - | bash

Follow the on-screen instructions, such as modifying your .bashrc file, then logout and log back in again.

Installing Perl

$ perlbrew install perl-5.16.0

This will install the version of Perl specified.

To use this Perl binary in the current shell...

$ perlbrew use perl-5.16.0

To use this Perl binary for all future shells...

$ perlbrew switch perl-5.16.0

You can use the following shebang line in your Perl scripts that you run on the command-line...

#!/bin/env perl

Be aware that this approach won't work by default for cron-jobs, since a shell isn't started for those, so you may need to hard-code the full path to the required Perl binary, ie, ~/perl5/perlbrew/perls/perl-5.16.0/bin/perl.

Installing Perl Modules

Use Perlbrew to install CPAN-minus, a modern version of the cpan command-line utility.

$ perlbrew install-cpanm
$ cpanm DBIx::Class

In Conclusion

You now have a self-contained Perl environment in which to work.  Testing the latest version of Perl is also quite straight forward, install the latest version, use it, and test away.

The only slight issue here is that you will need to install all the required CPAN modules again for each new build of the Perl binary, but to me this is a good thing, ensuring your MANIFEST is kept up-to-date.

There are procedures you can follow to take the list of installed modules from one installation and have cpanm re-install them on another, this is left as an exercise for the reader.

Leave Comment
Yay! You've decided to leave a comment. That's fantastic! Please keep in mind that comments are moderated. So, please do not use a spammy keyword or a domain as your name, or it will be deleted. Let's have a personal and meaningful conversation instead. Thanks for dropping by!