miércoles, 12 de mayo de 2010

You can stay at $HOME, Perl :)

Evolution is the way to keep up with times, and lots of things are happening in the perlsphere lately:
  • Perl 5.12 went stable on April 2010, with lots of fixes, and a few new features. See the deltas.
  • Rakudo is making progress at a good rate, with new contributors, and it's getting faster and more complete every day. Parrot guys are doing a great job there too.
  • cpanminus seems to be the next big thing of the language, and it's a perfect companion of local::lib and even perlbrew.
Cpanminus is miyagawa's (quite successful) attempt to simplify CPAN.pm, in a DWMI-Y way. by default, it follows dependecies, uses your prefered path to install modules (it knows about local::lib) , and will just install and get out of your way. It's better for perl newbies (and pseudo-newbies like me) and speeds up the installation of the whole environment.

local::lib is one of the wizard mst's magic spells to enable local repositories of libs per project. That means you can attach cpan libs to your apps, and then control the exact version you ship with each app.

the complete install process of the environment is the following:


mkdir ~/myperltmp
cd ~/myperltmp
wget cpanmin.us
chmod +x cpanm
wget http://search.cpan.org/CPAN/authors/id/M/MS/MSTROUT/local-lib-1.006000.tar.gz
tar zxvf local-lib-1.006000.tar.gz
cd local-lib-1.006000
perl Makefile.PL --bootstrap
make test && make install
echo 'eval $(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)' >>~/.bashrc


And now you're ready to go.
./cpanm DBIx::Class
./cpanm Moose

And with 0 questions, you'll have DBIx::Class and Moose in your ~/perl5 directory.

If you added the last line to your .bashrc, then everything should work. You can use local::lib "~otherpath"; to have multiple scenarios to try your modules/apps on. Next thing to try is perlbrew, but that's for another day.

Mainly I extracted the info from here and here (and perldocs, of course)

Before leaving, let me leave you with a great talk by mst. Full of info, and full of lolz, and nearly no swearing (Wow! surprise!)