in reply to Opendir and regex

You could instead call glob, which combines directory search and pattern matching on file names. With that you can write,

for (glob '*.{log,txt}') { -M > $expiration and system '/usr/bin/gzip', $_; }
Yet another way is with File::Find. That would be the choice if you wanted to process subdirectories, too.

After Compline,
Zaxo