Need help with Compress::Zlib code (inflation gives error)

F

firemanacab

Inflation 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 (<BIG>){
($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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top