Subject: | Inflation Error when uncompressing a bzip2 file of XML data |
Date: | Mon, 1 Jun 2009 15:19:28 +0200 |
To: | bug-IO-Compress [...] rt.cpan.org, pmqs [...] cpan.org |
From: | Nattiya Kanhabua <nattiya [...] gmail.com> |
Hello,
I am trying to read contents from a bzip2 file of XML data by using
IO::Uncompress::Bunzip2 (IO-Compress-2.019.tar.gz). The system is
running v5.10.0 built for x86_64-linux-gnu-thread-multi. My program
codes are as follows:
-------------------------------------------------------------------------------------------------------------------------------------------------------
#!/usr/bin/perl
use strict;
use warnings;
use IO::Uncompress::Bunzip2 qw( $Bunzip2Error );
my $file = shift(@ARGV) or die "must specify a MediaWiki dump of the
current pages";
my $buf;
my $read;
my $gz = new IO::Uncompress::Bunzip2 $file
or die "Cannot open $file: $Bunzip2Error\n" ;
print $read, " ", $buf, "\n"
while ($read= read($gz, $buf, 32768)) > 0 ;
die "Error reading from $file: $Bunzip2Error\n"
if $read < 0 ;
$gz->close() ;
-------------------------------------------------------------------------------------------------------------------------------------------------------
However, running the program failed and I got error messages like follows:
-------------------------------------------------------------------------------------------------------------------------------------------------------
<page>
<title>General Conference on Weights and Measures</title>
<id>7339</id>
<revision>
<id>779001</id>
<timestamp>2003-02-16T16:18:30Z</timestamp>
</revision>
Error reading from test.xml.bz2: Inflation Error: Data Error
$ 1;2c
-------------------------------------------------------------------------------------------------------------------------------------------------------
Please not that the XML data file is successfully parsed and read
using XML::Parser. So, I am not sure what I am missing in my code to
uncompress and read XML data. What does "Inflation Error" mean? Does
this "1;2c" have special meaning in Perl? Thank you for your kindly
help.
Nattiya