Richard Bucker

perlbrew and mojolicious

Posted at — May 25, 2012

I’m not a fan of the guys over at mojo but it’s probably the better of the Perl micro-webframeworks out there. So I was curious if mojolicious was going to work with perlbrew.The first thing I did was install perlbrew. There are several ways to do it. I decided upon the first option:curl -Lk http://xrl.us/perlbrewinstall | bashWhat I do not like about the above command is that the code is assumed to be good and safe. It would have been a little more helpful of the code were downloaded from CPAN.Once the module was installed. I was directed to add a line to my .bash_profile and then restart my terminal session. Easy enough.NOTE: I did not recall what the base version was so I edited the .bash_profile file again and commented out the line that I was instructed to include. Then I opened a new terminal session and executed the command:perl -vMy default/host perl version was 5.12.3. And I wanted to install perl 5.16.0 the latest and current version of perl:perlbrew install 5.16.0Easy enough! At this point there was a message on the console that suggested a tail command that I could use to monitor the build. That was easy too. In the end it took about an hour or so and I had a working Perl 5.16.0. (feel the perlbrew doc for the interesting commands)As a last step I wanted to see what was going to happen when I installed mojolicious, could it be installed in userspace, and which version was it doing to use. So I installed mojo:curl -L cpanmin.us | perl - MojoliciousI omitted the ‘sudo’ that the mojo guys recommended and it installed fine. But now the proof needed to be in the pudding. I created a hello.pl file:use Mojolicious::Lite;get ‘/’ => {text => ‘Hello World! ' . $] };app->start;Notice that I added the $] to the message. This is going to append the Perl version number to the end of the hello world string. The good news is that when I ran the application:morbo hello.pland launched my browser, I received a message that told me I was using Perl version 5.16.0. Perlbrew was a success and so was Mojo.