my $file = "file.gz"; open(IN, "gzcat $file |") or die "gunzip $file: $!"; while ( ) { ... } close(IN);