use strict;
use Compress::
Zlib;
my $infile =
$ARGV[0];
my $outfile =
$ARGV[1];
if (!
$infile || !
$outfile) {
print "$0 <infile> <outfile>\n";
exit;
}
my $buffer;
my $gz =
undef;
my $success =
1;
if (!
open FH,
"> $outfile") {
$success =
0;
print "Unable to write to '$outfile'\n";
}
else {
binmode FH;
print "GZ File = '$infile'\n";
print "OUT File = '$outfile'\n";
if ($gz = gzopen
($infile,
"rb")) {
while ($gz->
gzread($buffer) >
0) {
print FH
$buffer;
}
if ($gzerrno != Z_STREAM_END
) {
$success =
0;
print "ZLib Error: reading $outfile - $gzerrno: $!\n";
}
else {
$success =
1;
}
$gz->
gzclose;
}
else {
$success =
0;
print "ZLib Error: opening $infile - $gzerrno: $!\n";
}
close FH;
}