For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > November 2005 > Need help with Compress::Zlib code (inflation gives error)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Need help with Compress::Zlib code (inflation gives error)
firemanacab@yahoo.com

2005-11-17, 9:55 pm

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;

usenet@DavidFilmer.com

2005-11-17, 9:55 pm

firemana...@yahoo.com wrote:
> use Compress::Zlib;


Gosh, wouldn't it be much easier to read the documentation on the
module you're trying to use?

http://search.cpan.org/~pmqs/Compre...ssing_ZIP_Files

You might just realize you're using the wrong module for what you want
to do.

Ain't them docs amazin?

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com