http://www.perlmonks.org?node_id=1012212

space_monk has asked for the wisdom of the Perl Monks concerning the following question:

So I wrote this little application at work using XML::Parser, and then my line manager said "that works great, but the files are huge and I'd be much happier if it took .gz files as input. Now as far as I know, XML::Parser is based on expat, and if I had chosen to write my app using XML::LibXML::Parser instead, which uses the C libxml2 library, it would have taken .gz files as input automagically.

What's the easiest way to get my XML::Parser based app to process .xml.gz files with the minimum of changes?

A Monk aims to give answers to those who have none, and to learn from those who know more.

Replies are listed 'Best First'.
Re: Parsing zipped xml data
by Anonymous Monk on Jan 08, 2013 at 10:54 UTC
    gzcat, but you knew that already :)

      I probably did, but the grey cells that hold that information have been killed off by the influx of alcohol between XMas and New Year :-)

      Plus, I was interested to see various TMTOWTDI alternatives if there are any....

      A Monk aims to give answers to those who have none, and to learn from those who know more.
Re: Parsing zipped xml data
by Jenda (Abbot) on Jan 09, 2013 at 00:07 UTC

    The parse() method accepts an opened filehandle so something like

    use PerlIO::gzip; open my $IN, "<:gzip", "file.gz" or die $!; $parser->parse($IN); ...
    should work. (untested)

    Jenda
    Enoch was right!
    Enjoy the last years of Rome.