I am pretty sure that there must be some modules that do that (or at least part of that task). If not, I think it can be done easily in pure Perl in a few dozens of code lines at most. You need to sort your log files by date into an array and remove the oldest entries until you get below the threshold. I would be glad to offer some basic code if you gave some more details on the directory hierarchy where your files are stored.