use PerlIO::gzip; open my $fh, "<:gzip", $gzfile or die "$gzfile: $!\n"; binmode STDOUT, ":gzip"; while(<$fh>) { # do stuff print; }