in reply to unzipping unix files on windows

here is one way to do it. tested for .gz files. should also work for .Z files.

source: adapted from the compress::zlib example code.

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_STREA +M_END; $gz->gzclose(); close(OOTFIL);
hasta la vista
...wufnik

-- in the world of the mules there are no rules --

Replies are listed 'Best First'.
Re^2: unzipping unix files on windows
by spikey_wan (Scribe) on Jul 05, 2004 at 13:48 UTC
    Thanks for your help.

    Unfortunately, when I tried your code, it wouldn't do a .Z file. I get "Error reading from file...".