Sometimes asking nicely works… August 24, 2009
Posted by claudio in Perl, Programming.Tags: android, google, Perl
2 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 Perl, Solaris, UNIX.Tags: DBD::mysql, Mysql, Perl, Solaris, Solaris 10, UNIX
add a comment
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'Installing /usr/perl5/site_perl/5.8.4/sun4-solaris-64int/auto/DBD/mysql/mysql - 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 Perl, Programming.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 Perl, Programming.Tags: "Modern Perl", community, 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 Perl, Programming.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 Perl, Programming.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…
Object Oriented Perl? July 12, 2008
Posted by claudio in Perl.Tags: Java, OO, Perl
7 comments
I love perl. Really. This is not a post inspired by “5 things I hate about Perl“, but rather a question for the wider perl community out there (hi perlshere!). How do you write your OO perl code?
I have some code out there that follows the inside-out objects methodology of Perl Best Practices. Lately I have been writing java code, and inside-out objects feel like a lot of extra – not very intuitive – work to create your classes. I have been looking at Moose, but again it looks pretty cumbersome to create classes (constructors, named parameters for methods, returns, etc.). I am just probably missing a good howto (besides the cookbooks on cpan) or even a printed book on Moose. Any tips out there to get into Moose fast or a nice complete and intuitive alternative (extra points if it’s similar to java’s OO framework)? Thanks.
EDIT (Feb. 16th 2009): it seems I have a direct line with The Perl Foundation: a grant was approved for Dave Rolsky to work on the Moose documentation. Yannick greated a nice pdf output of the manual (see this as well).
CPAN on Ubuntu fails on bug IO/Uncompress/RawInflate.pm: solution May 30, 2008
Posted by claudio in GNU/Linux, Perl.Tags: bug, cpan, GNU/Linux, Linux, Perl, Ubuntu
13 comments

apt-gettable perl modules on Ubuntu are great. A nice packager at Debian Gnu/Linux compiled the modules and included all dependencies specially for you
.
This is extremely handy when you are looking for a solution for a programming problem that you know someone else solved before. You apt-get the modules you need and have a quick try.
While doing exactly this (tryng to install HTML::TextToHTML) , I discover CPAN on Ubuntu was broken:” Can’t call method “value” on an undefined value at /usr/share/perl5/IO/Uncompress/RawInflate.pm line 64.”.
I don’t think it’s a Debian/Ubuntu problem, but rather a upstream bug. Some people have the same problem on Windows. How nice the apt-gettable modules are, there are always cases when you need to build modules not yet in the Ubuntu repositories or you need a newer version (both cases here). A non-working CPAN is not acceptable. This is what I did. (more…)
Perl tip: get fancy parameters on a command line script May 23, 2008
Posted by claudio in Perl.Tags: Perl
add a comment

It is nice when your command line script has clear switches and parameters that have a long and short variant to please a different public. Have a look at this fictional example:
$ myscript.pl "config settings preferences" /var/tmp admin clean
or
$ myscript.pl --file config,settings,preferences --dir /var/tmp --user admin --clean
It’s undeniable that the last one looks more professional and less error prone. The user knows what kind of input is expected and he can type them in whatever order he/she wishes. When he/she is comfortable with your program he/she can even use a shorter notation. The program can be started like this with the same results:
An IDE for perl? May 23, 2008
Posted by claudio in Perl.Tags: Perl
add a comment
szabgab writes (aggregated on planet.perl.org) about the absence of a decent IDE for perl. To be correct, he rather acknowledges the existence of some IDEs like Eclipse + Epic or Komodo but he prefers to work with the old trusted vi + command line.
That’s fine, but like he writes in his post, some people expect an IDE as they are used to using one while developing in other languages, specially in the Windows world. In my case, I know my way pretty well in Unix (I use it professionally and at my desktop) and vi and still, I prefer to use an IDE. Why? (more…)









