http://www.perlmonks.org?node_id=457167


in reply to Re: Compressing Data On The Fly
in thread Compressing Data On The Fly

And in reading,

open my $fh, '<:gzip(autopop)', $file or die $!; This transparently falls back on ungzipped where the file is not compressed. There's a warning in the docs about using it, but in many cases it's an excellent tool.