Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

polettix (7564)

  (email not shown publicly)

Journal of polettix (7564)

Thursday January 03, 2008
03:14 PM

See you soon dada!

Tomorrow dada is leaving Roma for his new job adventure in Wien. If by chance any of you happens to be in Roma, we're going to have dinner together: write me (flavio at polettix dot it) if you're interested.
Thursday November 15, 2007
07:35 PM


Some days ago I finally uploaded to CPAN a first release of MMS::Parser, which is wandering in my PC since a long time. It's a library to parse binary MMS messages, for the moment supporting the two main "scenarios" regarding the outgoing message and the incoming one.

While it is more or less usable (my colleagues are using it in a demo application somewhere) it really lacks documentation, and test coverage is not complete.

Moreover, I'm planning to produce a real object hierarchy instead of a simple HoH, so I'll probably take a look somewhere around MIME::*.

Monday November 12, 2007
03:47 AM

ImageMagick 6.3.6

I upgraded to ImageMagick 6.3.6 last night and the nightmare of such things popped out: my scripts terminated suddenly with a "Segmentation fault". Ouch. On the other hand, the test suite for the Perl modules sort-of-worked, with some issues on a test file. So, it couldn't be *that* broken.

It ended up that it was a "coders" directory put somewhere, and in particular the ".so" library files that were in it. I don't really know anything about autoconf and libtool, but the most evident thing was that in the compiled directory there were two libraries for each file, one ending in ".so" and the other ending in ".soT", which was the one that got installed (and that caused the problem). And yes, the *dirty* hack to copy the original ".so" files over the broken ones worked.

I suspect that my compiling toolchain is a little dated... time to upgrade, I fear.

Monday September 03, 2007
04:37 AM

TheDamian vs. domm arm fight

After having completely enjoyed YAPC::EU 2007 (my first one!), I'm going through my photos and videos and so far I've uploaded two videos of the TheDamian-domm arm fight on YouTube. The first one is from the beginning to some time near the end.

I then realised that the quality was quite poor (due to digital zoom during recording), so I stopped, zoomed (optically) and was lucky enough to record the very end.


Thursday August 02, 2007
12:52 PM wishes good holidays

Yesterday we got together, at last! Happy partecipants were (in no particular order) Aldo, Chris, Marco, Stefano, Emanuele and I. Ok, there was a particular order, but nevermind.

We usually try to stay far away from Perl in these Mongers meetings, but we always fall down. Yesterday we had an interesting conversation about 'use vars' and 'our', with Emanuele being an advocate for 'our' (and citing the docs for 'use vars' being deprecated) and Aldo and I saying that 'our' was out of the 1337 clubs. Well, 'saying' is not completely true: we had that we-know-it-all-baby look and voice tone, but Emanuele is no baby at all and quickly disarmed us with the simplest of questions ("where did you read this? gimme references, and good ones!") and citing passes from the documentation at heart.

The bottom line is that neither Aldo nor I found the references we were thinking about, apart from a couple of rants by tilly on Perl Monks and a tutorial from Ovid. But I can swear that it was all Weisbeer's fault.

Marco was amazed by the simplicity of the Perl object system, which we tried to explain briefly. Thinking about it, I must admit that building an entire object system on more or less two user-tweakable things (bless and @ISA) is really *great*. Whatever the object system for Perl 6 will be :)

After what we can consider my first truly technical dinner in Perl, we found that we were hostage in the restaurant, but fortunately we had eaten enough to gain the possibility to get out (you have to spend a minimal amount of money in that place, it seems).

Thursday April 19, 2007
07:49 PM

One question about Perl 6

Last night (at least here in Italy) I asked a question about Perl 6, I hope TimToady won't sue me for reporting it here :) (Note: I eliminated a comment by Limbic~Region from the original log, that referred to another thread of discussion).

apr 19 01:22:02 <polettix>
         <disclaimer>I'm not asking for dates!</disclaimer>
         what percentage of Perl 6 specs definition do you
         think we (well... you) are at?
apr 19 01:22:56 <TimToady>
         we're well past the first 80% and well into the
         second 80%.  :)
apr 19 01:23:52 <polettix>
         nice answer, and I suspect it also represents the
         reality quite well :)
apr 19 01:23:56 <TimToady>
         in other words, most of the important stuff is
         done, and much of what remains is a protracted
         negotiation between the current design and the
apr 19 01:24:26 <TimToady>
         with assorted input from educators and users
apr 19 01:25:29 <TimToady>
         plus a gentle undercurrent of "keep everything
         else the same as Perl 5"

Saturday March 31, 2007
11:16 AM

Origami camel, at last!

At last I received Origami Sculptures by John Montroll, containing a diagram for a beautiful camel (it contains both the double-humped bactrian camel and the single-hump dromedary). Well, my camel is not so beautiful, but here it is!

(According to this, it seems that I have to state that the use of the Camel in association with Perl is trademark of O'Reilly, and that I have to link back to If you think that I'd so something more please let me know, I might have misunderstood the terms linked above for non-commercial usage).

Friday March 30, 2007
06:23 PM

IPC::Open3 quirks

I sometimes record some modules as possible "future save-the-day solutions" when I read about them, mostly on Perl Monks. One of these modules is IPC::Open3, but I'd take more care in ensuring these safe nets.

IPC::Open3 is useful when you want complete input/output control on a spawned process, i.e. when you have to control its STDIN, STDOUT and STDERR as well. The interface is quite straightforward:

$pid = open3(\*WTRFH, \*RDRFH, \*ERRFH,
             'some cmd and args', 'optarg', ...);

my($wtr, $rdr, $err);
$pid = open3($wtr, $rdr, $err,
             'some cmd and args', 'optarg', ...);

One thing that the docs state quite clearly is the following:

If ERRFH is false, or the same file descriptor as RDRFH, then STDOUT and STDERR of the child are on the same filehandle.

It's easy (at least for me) to overlook this, and you can imagine my surprise discovering that all the STDERR of the spawned process goes straight to STDOUT, and the filehandle for $err is undefined. What's not so easy is to discover how one can address this issue. IMHO, the "Do What I Mean" mantra has been spectacularly betrayed here, where I would expect a brand new handle to be created for me. Just like $wtr and $rdr, you know. Just like the filehandle in open().

Thanks to this thread, I discovered one solution to the problem: gensym. Here's a working snippet, at last:

# see also

use strict;
use warnings;
use IPC::Open3 qw( open3 );
use Symbol;    # provides gensym

my ($in, $out, $err);
$err = gensym();  # Aha! This was what I was after
my $pid = open3($in, $out, $err, '/bin/ls', '/path/to/inexistent', '/tmp')
  or die "open3(): $!";

my @emsg = <$err>; # The error comes from here
print {*STDOUT} "process STDERR: @emsg\n" if @emsg;

my @omsg = <$out>; # Output for existing stuff
print {*STDOUT} "process STDOUT @omsg\n" if @omsg;


poletti@PolettiX:~/sviluppo/perl$ perl
process STDERR: /bin/ls: /path/to/inexistent: No such file or directory

process STDOUT /tmp:

Something to remember well for the future...

Thursday March 29, 2007
08:52 AM

project's todo with hiveminder

Using Hiveminder's command line interface (described here), I put together this simple wrapper shell script:

if [ -z "$1" ] ; then --tag project-name list
else --tag project-name "$@"

that I install in the "bin" directory of my new projects. In this way, I'm able to track to-dos via this simple interface within the project ("project-name" above in the script is "rubrica" in the example below):

# List, by default
pinco@pallo /path/to/rubrica$ bin/todo
1H27 aggiungere le foto nella lista globale [rubrica]
1H35 verificare gli errori nella gestione delle pagine [rubrica]

# Todo set to "done"
pinco@pallo /path/to/rubrica$ bin/todo done 1h27
Finished task

# Task addition
pinco@pallo /path/to/rubrica$ bin/todo add 'verificare ordinamento per cognome'
Created task

# List (updated)
pinco@pallo /path/to/rubrica$ bin/todo
1H35 verificare gli errori nella gestione delle pagine [rubrica]
1KH7 verificare ordinamento per cognome [rubrica]

Update: I also added a little function into my .bashrc to automatically call the bin/todo script if available, or to call if not.

function todo () {
    if [ -e 'bin/todo' ]; then
        bin/todo "$@";
    else "$@";

In this way, when I'm inside the directory of one of my projects that have a bin/todo, this is what gets called. Otherwise, it is a simple proxy for the straight script.

Update: I ended up getting rid of the script and adding a simple .todo-tags file where I need it. I also substitued the shell function with the following script:


if [ -e '.todo-tags' ] ; then
   taglist=$(cat .todo-tags | sed 's/^/--tag /')
echo $taglist "$@" $taglist "$@"

In the .todo-tags all tags are on different lines and cannot have spaces, of course, but this works for me 100% of times.

Tuesday February 20, 2007
06:43 PM

The Sieve of Eratosthenes

Translating a python function for a sieve of eratosthenes (a way to detect prime numbers), I've come up with this:

sub eratosthenes {
   my %D;
   my $q = 2;
   return sub {
      while (defined(my $p = delete $D{$q})) {
         my $x = $p + $q;
         $x += $p while exists $D{$x};
         $D{$x} = $p;
      } ## end while (defined(my $p = delete...
      $D{$q * $q} = $q;
      return $q++;
} ## end sub eratosthenes

It's nice, even if it tends to blow for increasing values (due to memory requirements).