#!/usr/bin/perl

use Compress::Raw::Zlib ;

use strict ;
use warnings ;

binmode STDIN;
binmode STDOUT;

my $x = new Compress::Raw::Zlib::Deflate()
   or die "Cannot create a deflation stream\n" ;

my $output = '' ;

while (<>)
{
    $x->deflate($_, $output) == Z_OK
        or die "deflate failed\n" ;

    print $output ;
}

$x->flush($output) == Z_OK
    or die "flush failed\n" ;

print $output ;
