On Thu, Apr 2, 2009 at 12:36, Harry Putnam <[email protected]> wrote:
> I'm sure there is a technique for this, and actually think I once knew
> it, but striking out looking for it with no real idea what it might be
> called.
>
>
> I want to uncompress a file.gz (gzipped file) and write the
> uncompressed version somewhere for further manipulation.
>
> I think I recall some nifty way to do this without calling in gzip
> utility and just moving and uncompressing the file.
>
> Can any one point to some documentation or brief walkthru.

You have several options:

* Use the popen version of open

    open my $fh, "-|", "gzip", "-d", $filename
        or die "could not open $filename as a gzip archive: $!";

* Use the PerlIO::gzip[1] layer

    use PerlIO::gzip;

    open my $fh, "<:gzip", $filename
        or die "could not open $filename as a gzip archive: $!";

* Use IO::Uncompress::Gunzip

    use IO::Uncompress::Gunzip qw/$GunzipError/;

    my $fh = IO::Uncompress::Gunzip->new($filename)
        or die "could not open $filename as a gzip archive: $GunzipError";


1. http://search.cpan.org/dist/PerlIO-gzip/gzip.pm
2. http://search.cpan.org/dist/IO-Compress-Zlib/lib/IO/Uncompress/Gunzip.pm
 --
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to