Re: sort files by creation time
- From: merlyn@xxxxxxxxxxxxxx (Randal L. Schwartz)
- Date: 14 Dec 2005 07:56:52 -0800
>>>>> "Todd" == Todd W <toddrw69@xxxxxxxxxx> writes:
Todd> my @files = map $_->[0],
Todd> sort { $b->[1] <=> $a->[1] }
Todd> map [ $_, -M ],
Todd> grep -f, # get only plain files
Todd> glob("/mnt/qdls/MSDSIN/*");
Since the map can also serve as a grep, and we can use the _ handle
to avoid stat'ing twice, this can be simplified to:
my @files =
map $_->[0],
sort { $b->[1] <=> $a->[1] }
map { -f $_ ? [$_, -M _] : () }
glob "...";
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxxxxxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
.
- Follow-Ups:
- Re: sort files by creation time
- From: Paul Lalli
- Re: sort files by creation time
- References:
- sort files by creation time
- From: Brian Volk
- RE: sort files by creation time
- From: Brian Volk
- Re: sort files by creation time
- From: Todd W
- sort files by creation time
- Prev by Date: Re: Problem with regular expression
- Next by Date: Re: sort files by creation time
- Previous by thread: Re: sort files by creation time
- Next by thread: Re: sort files by creation time
- Index(es):
Relevant Pages
|