Need help with Compress::Zlib code (inflation gives error)
am 18.11.2005 03:23:41 von firemanacabInflation execution gives error status=0. I tried reading thru examples
in the manpage and elsewhere but just couldn't find the problem. I
tried inflating using Winzip but it gives error, could it be deflated
wrongly?
Deflation worked ok.
-----------inflation script--------------
#!/usr/bin/perl -w
use strict;
use Compress::Zlib;
my $small = 'small.zip';
my $big = 'new.html';
open(SMALL, "<$small") or die "$_";
open(BIG, ">$big") or die "$_";
my ($x, $input, $output, $status);
$x = inflateInit()
or die "Cannot create a inflation stream\n" ;
$input = '' ;
while (read(SMALL, $input, 4096)){
($output, $status) = $x->inflate(\$input) ;
print BIG $output
if $status == Z_OK or $status == Z_STREAM_END ;
last if $status != Z_OK ;
}
die "inflation failed\nstatus = $status " unless $status ==
Z_STREAM_END ; close BIG; close SMALL;
exit 0;
-------------deflation script below--------------
#!/usr/bin/perl -w
use strict;
use Compress::Zlib;
my $file = 'bbc_Nov_14_to_21.htm';
my $small = 'small.zip';
open(BIG, "<$file") or die "$_";
open(SMALL, ">$small") or die "$_";
binmode BIG;
binmode SMALL;
my $x = deflateInit()
or die "Cannot create a deflation stream\n" ;
my ($output, $status);
while (){
($output, $status) = $x->deflate($_) ;
$status == Z_OK
or die "deflation failed\n" ;
print SMALL $output ;
}
($output, $status) = $x->flush() ;
$status == Z_OK
or die "deflation failed\n" ;
close BIG;
close SMALL;
exit 0;