Get the latest Perl release with perlbrew December 10, 2010
Posted by claudio in Uncategorized.Tags: GNU/Linux, Perl, perlbrew, UNIX
7 comments
Updated: March 12, 2011.
Sometimes you want to leave your system Perl installation in peace and don’t really want to mix the system supplied Perl Modules and newer versions from CPAN. Or you want to use CPAN without sudo and without using PERL5LIB or local::lib. Or you may to test your code on older Perl releases. Or you simply can’t wait to use that shiny latest Perl release.
Good news. Perlbrew is a very nice addition to the “Modern Perl” wave resulting in a language and community revival of Perl 5 (that seems to have revitalized Perl 6 at the same time).
From the perlbrew CPAN page:
perlbrew is a program to automate the building and installation of perl in the user’s HOME. At the moment, it installs everything to ~/perl5/perlbrew, and requires you to tweak your PATH by including a bashrc/cshrc file it provides. You then can benefit from not having to run ‘sudo’ commands to install cpan modules because those are installed inside your HOME too. It’s a completely separate perl environment.
Here you’ll find how to use and customize perlbrew on a Debian/Ubuntu or Solaris installation. You don’t need g++ for perlbrew, but some modules from CPAN may need it later:
$ sudo apt-get install g++ curl
In case you use Solaris, install the Sunstudio compiler and make sure make and ar are in your PATH:
$ export PATH=/usr/bin:/usr/sbin:/opt/SUNW/spro/bin:/usr/ccs/bin
$ mkdir ~/lib
$ curl -LO http://xrl.us/perlbrew[...]
$ chmod +x perlbrew
The directory ~/perl5/perlbrew will contain all install perl executables, libraries, documentations, lib, site_libs. In case you don’t like the default, you can change it with the PERLBREW_ROOT shell variable. Change , and accordingly to your installation.
$ export PERLBREW_ROOT=~/lib/perlbrew
$ ./perlbrew install
The perlbrew is installed as:
/home/user/lib/perlbrew/bin/perlbrew
You may trash the downloaded /home/user/tmp/perlbrew from now on.
Next, if this is the first time you install perlbrew, run:
/home/user/lib/perlbrew/bin/perlbrew init
And follow the instruction on screen.
$ rm perlbrew
$ ~/lib/perlbrew/bin/perlbrew init
Perlbrew environment initiated, required directories are created under
/home/user/lib/perlbrew
Well-done! Congratulations! Please add the following line to the endof your ~/.bashrc.
After that, exit this shell, start a new one, and install some freshperls:
perlbrew install perl-5.12.1
perlbrew install perl-5.10.1For further instructions, simply run:
perlbrew
The default help messages will popup and tell you what to do!
Enjoy perlbrew at $HOME!!
$ echo "source /home/$USER/lib/perlbrew/etc/bashrc" >> ~/.bashrc
$ source ~/.bashrc
You can install new perl releases by typing by example “perlbrew install perl-5.12.3″. However, it may be a good idea to enable some features on the new compiled perl (mostly taken from the Ubuntu/Debian compile), specially the enabling of threading needed by a lot of perl programs (e.g. Padre):
$ perlbrew install perl-5.12.3 -Dusethreads -Duselargefiles -Dcccdlflags=-fPIC -Dpager=/usr/bin/sensible-pager -Doptimize=-O2 -Duseshrplib -Dcf_by="Your_name_here" -Dcf_email="Your_email@here"
Add the applicable parameters if you run a 64-bit OS or a Debian-based OS (like Debian or Ubuntu):
64-bit OS: -Duse64bitall
Debian-based OS: -Darchname=x86_64-linux-gnu -Dccflags=-DDEBIAN
Update if you are running Ubuntu 11.04. Ubuntu removed some links to libraries so if you build a Perl version previous 5.14, you need to the following:
for the 32-bit version: -Dplibpth=/usr/lib/i386-linux-gnu
for the 64-bit version: -Dplibpth=/usr/lib/x86_64-linux-gnu
(Thanks to Ahmad!)
Output:
[...]
Installed perl-5.12.3 as perl-5.12.3 successfully. Run the following command to switch to it: perlbrew switch perl-5.12.3
If you have several perl releases installed , you can choose the main perl by typing:
$ perlbrew switch perl-5.12.3
$ which perl
/home/claudio/lib/perlbrew/perls/perl-5.12.3/bin/perl
$ which cpan
/home/claudio/lib/perlbrew/perls/perl-5.12.3/bin/cpan
$ perl -v
This is perl 5, version 12, subversion 3 (v5.12.3) built for x86_64-linux-gnu-thread-multi
Copyright 1987-2010, Larry Wall
Perl may be copied only under the terms of either the Artistic License or theGNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found onthis system using “man perl” or “perldoc perl”. If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
A shiny new Perl to play work with…
Install DBD::mysql for Mysql 5 on Solaris 10 October 25, 2010
Posted by claudio in Uncategorized.Tags: DBD::mysql, Mysql, Perl, Solaris
add a comment
Installing DBD::mysql can be a little complicated because the needed libraries and header files are often not installed on Solaris or found in weird places (Howto on installing DBD::mysql with Solaris supplied mysql 4.0.31 and perl 5.8.4). This post explains how to install the module linked with Mysql 5.
To install the module do this:
- Install Mysql5. The paths on this post are applicable to the Sun Webstack installation in /opt/webstack. When using an other package or when compiling mysql yourself, change the paths accordingly. Remember that both perl and mysql must coincide in the binary format (32- or 64-bit). Because I use a self compiled 64-bit perl installation, the mysql binaries must be 64-bit as well.
- Download the tar ball of the modules or, easier, go to your cpan build directory (set at cpan configure time), typically at ~/.cpan/build/DBD-mysql-<VERSION> (already there if you previously tried to install the module with cpan).
- Run the makefile with the following arguments (adapt to your own needs if necessary):
$ cd ~/.cpan/build/DBD-mysql-<VERSION>
$ perl Makefile.PL --libs '-R/opt/webstack/mysql/5.0/lib/sparcv9/mysql -L/opt/webstack/mysql/5.0/lib/sparcv9/mysql -lmysqlclient -lz' --cflags '-I/opt/webstack/mysql/5.0/include/mysql -m64' --with-mysql=/opt/webstack/mysql
(After -lz you can add other options depending on your needs, like -lcrypt for ssl support.) - Complete the normal installation (make, make test (if you have a test db running), make install).
That’s it.
Compile the latest version of Perl on Solaris 10 September 14, 2010
Posted by claudio in Uncategorized.Tags: Perl, perlbrew, Solaris, Solaris 10, source
add a comment
Updated on Sept 09 2010.
Like on all UNIX operating systems, Solaris 10 supplies a Perl installation and it even adds its own modules in the Solaris namespace (yeah!). However, the version installed is 5.8.4, released on April 21, 2004 (boo!). Nowadays – in the Modern Perl’s times – you should use something as handy as App::perlbrew to install new versions of perl from source. As often in a corporate environment, however, it’s not always possible to directly reach the CPAN mirrors through perlbrew (proxy support is a work in progress). At the same time, it seems that a lot of people have trouble answering to the Configure questions to get the perl binary they need (at least 64-bit optimization and threads). This is how I compile perl on Solaris 10.
- Make sure you have the needed Solaris packages installed to compile C and C++ code. This is a good starting point. You can install the defaul Solaris compiler Sunstudio or gcc (provided as a SFW package in the installation media). Make sure the directories containing these binaries are in you PATH and /usr/ucb is not.
- Download the source, gunzip and untar it, cd to the directory.
- Run:
./Configure -ders -Dcc=cc -Dusethreads -Duseithreads -Ud_sigsetjmp -Uinstallusrbinperl -Ulocincpth= -Uloclibpth= -Duse64bitall -Ud_strerror_r -Ud_signbit -Duselargefiles -Dprefix=/opt/perl-5.12.2 -Dprivlib=/opt/perl-5.12.2/lib -Darchlib=/opt/perl-5.12.2/lib -Dsiteprefix=/opt/perl-5.12.2/site -Dsitelib=/opt/perl-5.12.2/site/lib -Dsitearch=/opt/perl-5.12.2/site/lib -Dman1dir=/opt/perl-5.12.2/share/man/man1 -Dman3dir=/opt/perl-5.12.2/share/man/man3 -Dsiteman1dir=/opt/perl-5.12.2/site/share/man/man1 -Dsiteman3dir=/opt/perl-5.12.2/site/share/man/man3 -Dsed=/usr/bin/sed -Duseshrplib -Dcf_by="<Your name here>" -Dcf_email=<Your e-mail here>
(Change <…> with valid vales. Also, if you run Configure more than once, make sure to remove config.sh and not rename to something starting with config.sh. As an alternative you can remove the Perl source dir altogether and untar the source file again.) - make
In this step, when using the Sun Studio compiler, make can be replace by the faster (parallel) “dmake”. make test
Update: there is a small bug concerning the following tests:Failed 5 tests out of 1747, 99.71% okay.../cpan/Archive-Extract/t/01_Archive-Extract.t../cpan/IO-Compress/t/010examples-bzip2.t../cpan/IO-Compress/t/010examples-zlib.t../cpan/IO-Compress/t/cz-05examples.t../cpan/Test-Harness/t/regression.tWhen you run the test by hand they are OK, so they can be safely ignored (thanks people on #p5p).
make install
NB: if you are creating a package instead of installing, you will need the switch -Dinstallprefix
Happy Recent Perl!
Fosdem 2010 Impressions February 19, 2010
Posted by claudio in Uncategorized.Tags: fosdem, Padre, Perl, photography
4 comments
This year’s FOSDEM was great. Not only did we have a Perl stand, but we could also meet face to face with other Padre developers. Here follow some loose impressions of the weekend…
Sometimes asking nicely works… August 24, 2009
Posted by claudio in Uncategorized.Tags: android, google, Perl
3 comments
Andy Lester was the first to point out that the we will have Perl support on the next release of Android! I guess asking nicely, does help.
I am not saying they listen to me, but I asked as well. ![]()
Install DBD::mysql for Solaris 10 system perl August 13, 2009
Posted by claudio in Uncategorized.Tags: DBD::mysql, Mysql, Perl, Solaris, Solaris 10, UNIX
10 comments
Installing DBD::mysql on Solaris 10 seems to be less trivial than “cpan DBD::mysql” when you want to use the system-supplied perl (5.8.4) and mysql (4.0.31) installation. Google shows a lot of people asking how to proceed, but surprisingly no answers. Typically, one gets this error at make time:
[...]
"dbdimp.c", line 4468: improper member use: com
"dbdimp.c", line 4468: improper member use: com
"dbdimp.c", line 4468: improper member use: com
"dbdimp.c", line 4630: undefined struct/union member: pmysql
"dbdimp.c", line 4653: undefined struct/union member: pmysql
cc: acomp failed for dbdimp.c
make: *** [dbdimp.o] Error 1
To install the module do this:
- Install the following Solaris mysql packages (if not already installed): SUNWmysqlr, SUNWmysqlu, SUNWmysqlS, SUNWmysqlt.
- Type the following as root:
cd /usr/sfw/share/src/mysql
./configure - Download the tar ball of the modules or, easier, go to your cpan build directory (set at cpan configure time), typically at ~/.cpan/build/DBD-mysql-<VERSION> (already there if you previously tried to install the module with cpan).
- Run the makefile with the following arguments (adapt to your own needs if necessary):
cd ~/.cpan/build/DBD-mysql-<VERSION>
perl Makefile.PL --libs '-R/usr/sfw/lib -R/usr/sfw/lib/mysql -L/usr/sfw/lib -L/usr/sfw/lib/mysql -lmysqlclient -lz -lposix4 -lcrypt -lgen -lsocket -lnsl -lm' --cflags '-I/usr/sfw/include -I/usr/include -I/usr/sfw/share/src/mysql/include' - Complete the normal installation (make, make test (if you have a test db running), make install).
That’s it.
Some ideas on method auto-completion in Padre June 9, 2009
Posted by claudio in Uncategorized.Tags: eclipse, epic, komode edit, netbeans, Padre, Perl, Programming
12 comments
Auto-completion is a nice feature for an IDE. While Padre supports some auto-completion functions, method auto-completion is an important missing feature. This post is a short round-up of features present in other IDEs.
What auto-completion features does Padre support today?
Beside automatic bracket completion, Padre has a nice auto-completion implementation for variables (first character -including sigil- then ctrl + p):

Eclipse + Epic
Epic (an add-on to Eclipse) has a nice working auto-completion feature activated by the method invocator (->).

As a reference, the java auto-completion in Eclipse:

Komodo Edit
Komodo Edit also has auto-completion for methods, but does not show those inherited from parent classes making the feature rather useless for OO development.

Netbeans
Netbeans has no Perl support, nevertheless the java auto-completion feature is a good example:

The method auto-completion feature is activated by the “.” (“->” in Perl). Not only you get a list of accessible methods (with expected parameter type and return value), but also the javadoc documentation for the selected method.
How should Padre support method auto-completion? Some ideas
- Method autocomplete should be activated by “->” and “::”. This way class hierarchies can be autocompleted as well. With “::” support for functions can be added.
- Private methods should be hidden. By convention, private methods start with “_”.
- Linking method autocomplete to perldoc is a winner combination when programming to not yet familiar APIs and certainly friendly to new Perl developers. While Perl is not strictly typed, a well formatted perldoc entry for a method should make clear what kind of parameters are expected and what the return value could be. However, documentation is rather freely formatted, so it would be difficult to implement in a generic way (without adding formatting restriction to classes).
Perl’s new wave February 16, 2009
Posted by claudio in Uncategorized.Tags: community, Modern Perl, Padre, Perl
5 comments
We all remember the “Perl is dead” hype from not so long ago. In short: Perl 6 wasn’t there yet and perl ironically wasn’t a copy of the language of the day (python, ruby, c#, …).
I was positively surprised by the response of the perl community. It wasn’t the typical “our programs run fast” (to ruby fanboys*) or “space as syntax wtf?” (to python fanboys). Instead it seemed that community took notice of the criticisms and made pretty clear that waiting for Perl 6 was not an option. Today, Perl 6 is doing fine (you can write code in Perl 6) and so is Perl 5.
So what did the community do? Well, Perl Best Practices -and corresponding module Perl::Critic- was a milestone telling people to stop writing perl 4 scripts and respect sane best practices to achieve clean and elegant code. Next to the many great modules already at CPAN (DBI::*, POE::*, DateTime, DBIx::Class (after PBP), WWW::*, etc), the community decided to address some clear shortcomings.
Moose (inspired by Perl 6) was an answer to one of the -in my opnion- greatest shortcoming of Perl 5: the basic OO framework. Perl-based Catalyst jumped on the Ruby-On-Rail wagon. chromatic, a core developer and important community member, started to think out loud what actually “modern perl” means and how we can improve perl by getting rid of obsolete features and bad practices.
An other missing piece, was a beginners-friendly and perl-centric IDE. Padre is aiming to fill this need. Gabor Szabo was able to quickly form a community developing padre (including Alias of Strawberry Perl and PPI fame). I guess this was the kind of project I was waiting for.
I hope that by being part of this project I can contribute to this positive perl new wave.
* fanboy != user
High-Order Perl now legally available online December 10, 2008
Posted by claudio in Uncategorized.Tags: "High Order Perl", ebook, Perl, Programming
add a comment
In case you haven’t read it elsewhere, High-Order Perl written by Mark Jason Dominus is now legally available on-line without cost. Get it here.
Of course, if you find the book useful and/or interesting you should buy it. You will not only acknowledge Mark’s work, but you will keep the Perl book micro-cosmos alive. Books that help you learn and widen your knowledge are a must for a language to flourish (not only for languages, by the way).
Having the real thing before buying gives you the power as a programmer to decide if it’s worth your money (no one can buy 1000 books). This beats reading reviews, table of contents or even a quick look in the bookstore.
Thanks for the trust, Mark.
An old answer to a common Perl question: name of a variable as a variable? November 8, 2008
Posted by claudio in Uncategorized.Tags: Perl
1 comment so far
While randomly “googling” I found an interesting news post from 1998:
People show up in comp.lang.perl.misc all the time asking how to use the contents of a variable as the name of another variable. For example, they have $foo = ‘snonk’, and then they want to operate on the value of $snonk.
That’s very easy to do in Perl, so they usually get some people to tell them to do it. And they usually get some people asking them why they didn’t use a hash instead.
As a Perl programmer it’s probably one of the most common questions you will hear from people learning Perl. I remember posing the same question back then (before I got to the chapters of references and hashes
). Anyway, it’s a nice read and it may be an useful link for the next time (soon) someone asks you this question…















