use Compress::Zlib; my $fil = shift || die ("need compressed file, stopped"); die "$fil not a gz'd file, stopped" unless (($fil =~ /.gz$/) || ($fil =~ /.Z$/)); (my $rootfil = $fil) =~ s/.gz$//; open OOTFIL, ">$rootfil" or die ("cannot open file for gunzip"); binmode OOTFIL or die ("cannot binmode $rootfil"); $gz = gzopen($fil, "rb") or die ("can't open $fil, $gzerrno, stopped"); my $buffer; print OOTFIL $buffer while $gz->gzread($buffer) > 0; die "Error reading from file $file: $gzerrno\n" if $gzerrno != Z_STREAM_END; $gz->gzclose(); close(OOTFIL);