How can I sort files by timestamp without slurping?



hi are you doing everybody...

How can I sort files by timestamp without slurping?

the idea is to look into a directory, pick up the oldest first and so
on until the 'youngest' one.
file100..all the way to file1.

I found this solution somewhere,

my @sorted = map { $_->[0] }
sort { $b->[1] <=> $a->[1] }
map { [ $_, -M $_ ] }
@files;

By the looks of it, it does slurp the all the files from the source
directory into an array and does the sorting there.

I'm thinking on incorporating a timestamp sorting mechanism without
slurping.

Since above solution looks like sorcery of some kind to me,
How can I modify it to fit below? or if you have any other ideas
please let me know. Thanks in advance.

MOVE_FILES:
while (defined (my $file = readdir (SOURCEDIR))){

#skip . and .. files
next MOVE_FILES if $file =~ m#^\.\.?$#;

#the sorting should it take place here I guess.


#move files
move ($file, $target_path) or die $!;


}

.



Relevant Pages

  • Re: How can I sort files by timestamp without slurping?
    ... How can I sort files by timestamp without slurping? ... I'm thinking on incorporating a timestamp sorting mechanism without ...
    (perl.beginners)
  • Re: file numbering
    ... OEX will prepend or append a timestamp to the ... filename as well to allow for sorting based on subject / date or date / ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: data structure selection
    ... BTW do you need sorting with the page number? ... > I face the problem to select the approprate data structure ... > objects like timestamp, date and ID. ... > comparison for delete/override the pointers with the current page number. ...
    (comp.lang.java)