I have a directory tree in the following format:
20040202/
20040202/file1
20040203/
20040203/file1
20040203/file2
20040203/file3
20040204
20040204/file1
20040204/file2

First, I'd want to read in top level dirs in the order of 20040204,
20040203, then 20040202.  Then the files in each dir in descending order w/
time of creation as well.  I could read each handle, do a stat to sort them,
then process.  Thoughts?

Thanks in advance!


-----Original Message-----
From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 04, 2004 1:40 PM
To: Li, William; [EMAIL PROTECTED]
Subject: Re: Sorting directory content using creation time


> Hi,
> 
> Does anybody know if there is an option in readdir to return the file list
> in the order of their creation time?  Or know of a way to do that?  Been
> reading the perldoc w/o much luck.  Thanks!
> 

Doubtful, but it should be trivial using readdir in a list context and
using 'sort' with 'stat'.  

perldoc -f sort
perldoc -f stat
perldoc -q sort

The bigger question is "are you sure you want to?" the "creation time"
on most OSes doesn't actually mean anything or exist at all.  There is
the 'ctime' which is an inode change time which means even less to most
Perl programs.  Are you positive your OS supports a creation time?  What
are you really trying to do?

http://danconia.org

------------------------------------------------------------------------------
This message is intended only for the personal and confidential use of the
designated recipient(s) named above.  If you are not the intended recipient of
this message you are hereby notified that any review, dissemination,
distribution or copying of this message is strictly prohibited.  This
communication is for information purposes only and should not be regarded as
an offer to sell or as a solicitation of an offer to buy any financial
product, an official confirmation of any transaction, or as an official
statement of Lehman Brothers.  Email transmission cannot be guaranteed to be
secure or error-free.  Therefore, we do not represent that this information is
complete or accurate and it should not be relied upon as such.  All
information is subject to change without notice.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to