Re: reading a directory, first files the newest ones
- From: xhoster@xxxxxxxxx
- Date: 28 Oct 2007 01:34:24 GMT
jordilin <jordilin@xxxxxxxxx> wrote:
When I read a huge directory with opendir,
opendir(DIR,"dirname");
my $file;
while($file=readdir(DIR))
whatever...
it loads the oldest ones first. I would like the newest files first,
instead of the oldest.
That is completely up to your OS and your file system. Perl just provides
a fairly simple conduit for their behavior to reach you.
Taking into account that I am only interested
in the newest files, this takes a lot of time, as the directory is
really huge. I am talking about thousands and thousands of files. I
need to process the files that are two hours old from now. I am not
interested in those older than two hours ago. I know that because I
check the modification time with stat.
any idea?
Come up with a better directory structure; one that doesn't involve keeping
thousands and thousands of file in one directory that has to be scanned
over and over again. Or make whatever puts the files into that directory
to make a log, or to also create a symbolic link in another directory
pointing to the new file, which link can be deleted after 2 hours or so.
Its possible that your OS and your file system provide other tools for
inspecting very large directories more efficiently, but I rather doubt it.
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.
.
- References:
- reading a directory, first files the newest ones
- From: jordilin
- reading a directory, first files the newest ones
- Prev by Date: reading a directory, first files the newest ones
- Next by Date: Re: reading a directory, first files the newest ones
- Previous by thread: reading a directory, first files the newest ones
- Next by thread: Re: reading a directory, first files the newest ones
- Index(es):
Relevant Pages
|