in reply to read directory
It might be more efficient to call ls, if the number of files in the directory is large. You certainly don't want to call -M from inside a sort, as shmem suggests.
The -1 modifier forces output to one column, and -t sorts by last time modified.my @files = split /\n/, `ls -1t`; for (@files) { ... }
In Section
Seekers of Perl Wisdom