You are here

Perl

Image: 

Perl advent calendar 2006

Perl

The Perl Advent calendar is back with an edition for 2006 on a new homesite !

Killing my children

Perl

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

Perl

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

Perl

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.

Writing serious Perl

Perl

Perl's extremely flexible syntax makes it easy to write code that is harder to read and maintain than it could be. This article describes some very basic practices for a clear and concise style of writing Perl. It has even a link to the Perl design patterns wiki.

Pages

Subscribe to RSS - Perl