I'm not exactly sure what you mean, but perhaps this is
along the lines of what you were thinking:
foreach (sort {-M $a <=> -M $b} <*>)
{
# ...
}
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.
If, instead, you mean you want to get all files within a
certain modification period, you might want to go about it
this way:
$oldest = 5; # Days
$newest = 1;
foreach (<*>)
{
next unless (-M $_ < $oldest && -M $_ > $newest);
# Do stuff
}
Of course, you could condense this into a list with grep,
something like:
$oldest = 5; # Days
$newest = 1;
foreach (grep {-M $_ < $oldest && -M $_ > $newest} <*>)
{
# Do stuff
}
Typically, though, you would likely use readdir instead of
a glob for this kind of read. | [reply] [d/l] [select] |
Globbing implemented in Perl and many other shells works
with file names only.
So you can say <*.c> to match all the files ending in .c there's no
direct notation to match, say, all the files created in 2001.
Use File::Find instead, you'll be able to match
files according to their timestamps (three timestamps per file, actually) and much more.
-- TMTOWTDI
| [reply] [d/l] [select] |