Re: reading a directory, first files the newest ones
- From: xhoster@xxxxxxxxx
- Date: 28 Oct 2007 02:47:38 GMT
Gunnar Hjalmarsson <noreply@xxxxxxxxx> wrote:
jordilin wrote:....
On Oct 28, 2:02 am, Gunnar Hjalmarsson <nore...@xxxxxxxxx> wrote:
Maybe you should let the system do the desired sorting. On *nix that
might be:
chomp( my @files = qx(ls -t $dir) );
foreach my $file (@files) {
last if -M "$dir/$file" > 2/24;
print "$file\n";
}
The solution would be reading the newest ones first.
And that's what the -t option achieves...
No, the -t option tells ls to *present* the newest ones first, not to
read them first. To present them in that order, it first needs to read all
of the directory entries in whatever order the file system deigns to
deliver them, stat them all, and sort the results based on time. There is
no reason to think that ls is going to be meaningfully faster about this
than perl will.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
.
- Follow-Ups:
- Re: reading a directory, first files the newest ones
- From: Gunnar Hjalmarsson
- Re: reading a directory, first files the newest ones
- References:
- reading a directory, first files the newest ones
- From: jordilin
- Re: reading a directory, first files the newest ones
- From: Gunnar Hjalmarsson
- Re: reading a directory, first files the newest ones
- From: jordilin
- Re: reading a directory, first files the newest ones
- From: Gunnar Hjalmarsson
- reading a directory, first files the newest ones
- Prev by Date: Re: reading a directory, first files the newest ones
- Next by Date: Re: need help with hash - been too long working in Perl
- Previous by thread: Re: reading a directory, first files the newest ones
- Next by thread: Re: reading a directory, first files the newest ones
- Index(es):
Relevant Pages
|