XML::Parser or XML::LibXML?

That’s an easy question to answer: XML::LibXML!

I have over 10,000 lines of XML input. Parsing it into a tree with XML::Parser takes about 0.77 seconds, while XML::LibXML is over ten times faster, clocking in at 0.07 seconds.

use strict;
use Benchmark qw( cmpthese timethese :hireswallclock );
use XML::Parser;
use XML::LibXML;

sub xml_parser {
    my $p1 = new XML::Parser(Style => 'Tree');
    my $tree = $p1->parsefile('database.xml');

sub xml_libxml {
    my $p1 = new XML::LibXML;
    my $tree = $p1->parse_file('database.xml');

my $results = timethese(15,
        'XML::LibXML' =&gt; \&amp;xml_libxml,
        'XML::Parser' =&gt; \&amp;xml_parser,
print "\n";

The results are pretty damning:

XML::LibXML: 1.06607 wallclock secs ( 1.01 usr +  0.03 sys =  1.04 CPU) @ 14.42/s (n=15)
XML::Parser: 11.5305 wallclock secs ( 9.20 usr +  1.14 sys = 10.34 CPU) @  1.45/s (n=15)

              Rate XML::Parser XML::LibXML
XML::Parser 1.31/s          --        -91%
XML::LibXML 14.4/s       1005%          --

Now it’s off to write a schema for our wondrous XML dialect.

Fatlabel – modify DOS volume labels on Linux/UNIX

When inserting USB keys and memory cards on my Linux laptop they are automatically mounted and labeled with whatever name is on the (v)fat volume. I sometimes like to change that. Strangely enough, there is no standard utility for Linux/UNIX to change the volume name of a (v)fat partition.

Not that it’s difficult… I found a good explanation of how the (V)FAT boot sector is structured and managed to write a little perl script around it to manipulate the volume label.


Documentation is included. After installing, ”man fatlabel” should give you the dirt.