Just a small snip to rotate logfiles... The files are in the directory with a prefix (file) and a number appended
file.1 file.2 file.3 .... This will take the files and rotate them to the next greatest number upto the set history size. I'am sure that it can be done shorter/quicker .. but it's a start!
UPDATE: cleaned up code using
blazar's comments
use strict;
use warnings;
my $log_dir = "dir";
my $log_pre = "file";
my $hist_size = 10;
foreach(sort {($b =~ m/(\d+)$/)[0] <=> ($a =~ m/(\d+)$/)[0]} <$log_dir
+/$log_pre.*>){
my $f=$_;
s/(\d+)$/$1+1/e;
if($1 >= $hist_size){ unlink $f; }else{ rename $f,$_; }
}