my $file = 'some_file.gz'; open my $fh, "gzip -cd $file |" or die "Couldn't read/decompress '$file': $!"; while (<$fh>) { ... };