Re: sort files by creation time



>>>>> "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!
.



Relevant Pages

  • Re: sort files by creation time
    ... > Since the map can also serve as a grep, and we can use the _ handle ... > to avoid stat'ing twice, ... when your Schwartzian Transform just isn't ...
    (perl.beginners)
  • something like PL/I PUT DATA
    ... Especially in debugging I write a lot of code like this: ... I have not figured out a way to avoid having to type each name twice, ... to stop you mislabeling a value. ...
    (comp.lang.java.advocacy)
  • Re: php idiom to replace shell grep
    ... To speed up the script I wanted to avoid the repeated ... execution of shell_command. ... the grep and sed calls? ...
    (comp.lang.php)
  • Re: sort files by creation time
    ... and we can use the _ handle to avoid stat'ing twice. ... See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! ...
    (perl.beginners)
  • Re: Firefox lock file?
    ... --exclude-dir uses GLOB expressions which are different than REs. ... The man page I have in bash for grep, ... brackets only specify groups, or ranges of characters or numbers, from ...
    (Ubuntu)