open my $fh, "gunzip -c $filename |"; while (<$fh>) { # work with one line at a time here }