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

Discussion in 'Perl Misc' started by firemanacab@yahoo.com, Nov 18, 2005.

  1. Guest

    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;
    , Nov 18, 2005
    #1
    1. Advertising

  2. Guest

    , Nov 18, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Tony
    Replies:
    0
    Views:
    1,436
  2. ixtahdoom
    Replies:
    0
    Views:
    545
    ixtahdoom
    Jun 15, 2004
  3. Mike
    Replies:
    1
    Views:
    951
    John Harrison
    Aug 3, 2003
  4. ngoc

    error in Compress-Zlib-1.32

    ngoc, Dec 16, 2003, in forum: Perl Misc
    Replies:
    2
    Views:
    93
  5. Marc Bauer
    Replies:
    13
    Views:
    550
    Dr.Ruud
    Jul 23, 2006
Loading...

Share This Page