in reply to Getting a list of files in a directory sorted by date
I'm not sure how expensive pulling the date for a file is, but assuming it's reasonably exensive and you have a lot of files, then a Schwartzian Transform is a natural way to go.
opendir DIR, $logdir or die "Cannot open $logdir: $!"; my @cfiles = map { $_->[1] } sort { $a->[0] <=> $b->[0] } map { [ -M $_, $_ ] } grep { /\w/ } readdir DIR;
Update: Fixed the typo that slloyd and philcrow pointed out (/w/ should have been /\w/).
Cheers,
Ovid
New address of my CGI Course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting a list of files in a directory sorted by date
by philcrow (Priest) on Apr 07, 2006 at 17:54 UTC | |
|
Re^2: Getting a list of files in a directory sorted by date
by slloyd (Hermit) on Apr 07, 2006 at 17:04 UTC | |
by Ovid (Cardinal) on Apr 07, 2006 at 17:28 UTC | |
by slloyd (Hermit) on Apr 07, 2006 at 18:02 UTC |