use PerlIO::gzip; open( INPUT, "<:gzip", "old.gz" ) or die "old.gz: $!"; open( OUTPUT, ">:gzip", "new.gz" ) or die "new.gz: $!"; while () { # do something with a line of text... s/[\r\n]+/\n/; # for example, normalize line terminations print OUTPUT; }