in reply to rename files with mtime
opendir requires closedir (not close).
A common technique when using sort is to precalculate anything expensive (-M in this case) using a map before the sort then extract the desired data using another map after the sort:
my @list = map {$_->[1]} sort { $a->[0] <=> $b->[0] } map {[-M "$maillog_dir/$_", $_]} ...
|
|---|