Sorting
- From: ExecMan <artmerar@xxxxxxxxx>
- Date: Sat, 12 May 2012 15:54:22 -0700 (PDT)
Hi,
I'm looking to read a directory to get a list of files in Descending
sorted order by timestamp. I've gotten this so far, but it is in
ascending. Can anyone help with the descending part?
my $dir = '/home/logfiles';
opendir my $DH, $dir or die "Cannot opendir '$dir' $!";
my @sorted_files =
map $_->[1],
sort { $a->[0] <=> $b->[0] }
map -f "$dir/$_" ? [ ( stat _ )[9], $_ ] : (),
readdir $DH;
for ($i=0; $i<20; $i++) {
print "FILE: $sorted_files[$i]\n";
}
Thank a bunch!
.
- Follow-Ups:
- Re: Sorting
- From: Jürgen Exner
- Re: Sorting
- From: Tim McDaniel
- Re: Sorting
- From: Ben Morrow
- Re: Sorting
- From: ntua
- Re: Sorting
- Prev by Date: hash
- Next by Date: Re: hash
- Previous by thread: hash
- Next by thread: Re: Sorting
- Index(es):
Relevant Pages
|