in reply to globbing by timestamp
This will, in theory anyway, sort based on last modification time. -M returns a floating point value that is "days since last modification", and can be something like 0.2551 depending on your file.foreach (sort {-M $a <=> -M $b} <*>) { # ... }
Of course, you could condense this into a list with grep, something like:$oldest = 5; # Days $newest = 1; foreach (<*>) { next unless (-M $_ < $oldest && -M $_ > $newest); # Do stuff }
Typically, though, you would likely use readdir instead of a glob for this kind of read.$oldest = 5; # Days $newest = 1; foreach (grep {-M $_ < $oldest && -M $_ > $newest} <*>) { # Do stuff }
|
|---|