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


in reply to How to read from rotated log file?

I assume your system numbers log files, and that compressed log files end in .gz.

Let's assume your base file is called "my-app". Then it's time to use magic open! Untested:

my @files = </var/log/my-app*>; /\.gz/ and $_ = "zcat $_ |" for @files; local @ARGV = @files; while (<>) { ... do something with record ... }
This will read uncompressed files in the usual way, and read from a pipe (with zcat on the other end) for compressed files.