in reply to How do I traverse the files in descending order of modification using File::Find
You can have files be sorted on a per-directory basis using the 'preprocess' option, but you cannot sort the complete set of files across the entire directory tree you're traversing, such that File::Find would report the oldest file of all files first (at least I wouldn't know how). If you need that, you'd have to store everything into an intermediate array, and then sort that yourself.
"preprocess"
The value should be a code reference. This code reference is used to preprocess the current directory. The name of the currently processed directory is in $File::Find::dir. Your preprocessing function is called after "readdir()", but before the loop that calls the "wanted()" function. It is called with a list of strings (actually file/directory names) and is expected to return a list of strings. The code can be used to sort the file/directory names alphabetically, numerically, or to filter out directory entries based on their name alone. When follow or follow_fast are in effect, "preprocess" is a no-op.
|
|---|