Perl

Programmer's Pandora box

Topics

I just encountered a situation which I like to call a programmer's Pandora box : imaging you're testing a fix for a small bug in an otherwise bug free, beautifully coded program. A routine job like any other. Suddenly, during the tests you discover a new bug in a completely different part of the program. You fix that bug too, but during the next test run, another bug pops up which leads to a chain of bugs and fixes with an increase in anger, hate and suffering.

I discovered that you should stop after 3 encountered bugs, after which you should take a break/coffee/nap. Stopping will give you an uncanny and unhappy feeling, during which the Pandora box will continue to haunt your mind, but failing to do so will lead to a completely mutilated program.

Killing my children, part 2

Topics

I don't think anyone will notice, but I removed my home-brewn RSS feed daemon from this site, which was my own implementation of XULChannels. The software has been superseded by various RSS feedreaders and Planet software, and even I didn't consulted it anymore.

Killing my children

Topics

I recently got subscribed to Google Reader, and I love it. A nice Web2.0 application for browsing RSS subscriptions. And one that puts my own home-brewed Darkchannels into the shadow. I started it to get my own XULChannels, and it did what it had to do, but the last two years, I even didn't had time to change one bit.
The same for the GDM Bluecurve theme, which is basically caught up by time. So from today I won't link them on this page, and by time they won't be available any more on this site.

Vim for Perl developers

Topics

Even more Vim goodies : Leonid Mamchenkov posted some clear and simple instructions about Perl programming with Vim. Most of it covers the scripts for Perl on vim.org, but it listed some nice vim settings I never knew about (eg the listchars option for vertical indentation).

Only thing I miss from a modern IDE (eg Eclipse with the EPIC plugin) is the option of showing command definitions (foreach, confess, split, ...) with a function key. You can summon Perldoc from Vim, but that does not cover function and statement syntax. Can someone provide any clues ?

Sucking XML in Perl

Topics

I'm working on some XML stuff in Perl, and took quite some time to explore the available XML parsers in Perl. There are quite a lot of them, so choosing the right one isn't allways easy :

* XML::Twig looks quite interesting and powerfull, but has quit a steap learning curve due to the imo cumbersome interface, espacially the twighandler stuff. Not intended if you want to do something quickly in Perl, unless you have the Twig experience.

* XML::Simple seemed a good tool so I started implementing using this module, but the performance is horrible : it took 14 seconds to parse a document around 3500 lines big, which took me straight back to the drawing board.

* XML::Parser was close to what I wanted, but the output was too cluttered, certainly if you're working with more complicated XML files.

* XML::LibXML is a module specifically built to corner some of the performance issues of XML::Simple, but it was built around the Gnome XML libraries, which weren't available on the HP-UX 11.11i server.

* XML::Smart seemed a great and intuitive interface for my problem. Unfortunately it isn't available in the default Perlmods, this could not be used. As it had quite some dependancies, installing it on the server wasn't an option.

There are also the SAX modules, but they seem more stuff you want to use when you're working in framework related stuff, and the SAX thing seemed too much of a burden to carry around (the program wasn't that big after all...).

So what did I do then ? As far as speed goes, the reality seems to be: a regexp-based, non-XML parser is going to be faster than a "close to the metal" parser (XML::Parser or XML::LibXML), which is going to be faster than a more convenient parser (XML::Simple, XML::Twig) which is going to be faster than a pipeline involving passing events througth various object-oriented layers (XML::SAX). So with that in mind, I implemented my own regexp based XML parser. It took to my surprise only half an hour to get it working, and was about 1500% faster than XML::Simple.