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 () { # $_ contains one line of uncompressed text data per iteration do_something($_); }