use strict; use PerlIO::gzip; ( @ARGV == 1 and -f $ARGV[0] and $ARGV[0] =~ /\.gz$/ ) or die "Usage: $0 file.gz\n"; open( IN, "<:gzip", $ARGV[0] ) or die "open failed on $ARGV[0]: $!\n"; while (<IN>) { # $_ contains one line of uncompressed text data per iteration do_something($_); }
UPDATE: (2010-10-18) It seems that PerlIO::gzip should be viewed as superseded by PerlIO::via:gzip. (see PerlIO::gzip or PerlIO::via::gzip).
In reply to Re: unpacking .gz from perl
by graff
in thread unpacking .gz from perl
by karpatov
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |