You could try something along these lines, where I create an array
prepending the date in Perl time format and then sort the array. There
is probably a better way, but this would work.
Note: (stat $file)[9] is a list slice that represents only the 9th
element of the list returned by 'stat $file'. Check out 'perldoc -f
stat'
###########################################
use strict;
use warnings;
opendir(DIR,".") or die("Couldn't open '.'!");
my @files = readdir(DIR);
foreach my $file(@files){
#prepend the modified time
$file = (stat $file)[9].'#'.$file;
}
foreach my $sorted_file(sort @files){
#strip out the modified time so we're left with the file name
$sorted_file =~ s/^\d+\#//;
print "".localtime((stat $sorted_file)[9])." => $sorted_file\n";
}
############################################
-----Original Message-----
From: Brian Volk [mailto:[EMAIL PROTECTED]
Sent: Monday, December 12, 2005 9:33 AM
To: '[email protected]'
Subject: sort files by creation time
Hi All~
<snip>
I would like to process the File 1 first then File 2 and then File 3.
Each
file contains data that I need to print for that order. If I can
process
the orders (File 1, File 2, File 3) according to the time they entered
the
given dir (first in/first out) the data will print off in the correct
sequence.
<snip>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>