Eric Vercelletto wrote: > Hi All, > > I'm writing a script that must list the files contained in a folder. This > list should be ordered by timestamp of file creation ( ie file creation > date). > I have tried the following pseudo-code: > initialize an array of structures: {creationdate, filename} > opendir DIRNAME > > @ListOfFiles = readdir DIRNAME > foreach ( @ARRAY ) { > creationdate_structure = stat ( $_ ) > create the new array element with creation date and file name > } > sort the new array > > which is ok but extremely slow if I access to remote folders thru the Local > Area Network because I have to access to 10s of thousands of files > > 1) question # 1: > does the output of readdir, without any sort, have any specific order (by > chance creation date of the file?)
Not that I'm aware of. > 2) question # 2 > if there any way to sort the contents of a folder by the creation date of > the contained files? Sure, but I'm not sure how accurate creation time is on Windoze. You'll need to stat each file and sort on the saved time. Modification time is usually a better bet if it suits your needs. You could save the name as the key and the ctime as the value in a hash and then sort the hash by value (to keep the two sync'd together). _______________________________________________ Perl-Win32-Admin mailing list Perl-Win32-Admin@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs