RE: sort files by creation time



After running a few tests... :~) I think I might be able to sort on the
inode... ? Does this make sense?

my @files = glob("/mnt/qdls/MSDSIN/*");

foreach my $file (@files) {

print "$file\n";
my $ino = (stat($file))[1];
print "ino is $ino\n";

Thanks!

Brian

-----Original Message-----
From: Brian Volk [mailto:BVolk@xxxxxxxxxxxxxx]
Sent: Monday, December 12, 2005 12:33 PM
To: 'beginners@xxxxxxxx'
Subject: sort files by creation time

Hi All~



I'm using the glob function to grab all the files in a given directory and
then using crontab to check it every 5 minutes. Once I have the files I'm
using the diamond operator to read every line in every file and *do
something* if the line matches. Here's my questions:



Given directory:

File 1 - in dir at 9:01

File 2 - in dir at 9:02

File 3 - in dir at 9:03



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.



Is there a module I can use for this? Maybe File::Stat? Or can I do a sort
of some kind right after the while <> ?



Can someone pls let me know what function I'm supposed to use or which
module I need.



Thanks!!!







Below is some of the code:



I'm using the code below to check if there are any files in the dir. If so,
then goto to the PMSDS sub.



my @files = glob("/home/bvolk/test_msds_in/*");



my $count = ();

foreach my $file (@files) {

$count++;

if ($count > 0) {

&PMSDS;

last;


}

}





-----some of the PMSDS sub



@ARGV = map { "$orders_dir/$_" } grep { !/^\./ } readdir ORDERS;



my %DIR_LIST;



$DIR_LIST{$_} = 1 for @pdfs;



while (<>) {

chomp;

$_ =~ s/\s+\z//;



if(exists($DIR_LIST{$_})){

my $basename = fileparse($ARGV,'.TXT');

$basename =~ s/O//;

$_ =~ s/.pdf//i;



print "Job $basename printing msds $_\n";

} else {

my $basename = fileparse($ARGV,'.TXT');

$basename =~ s/O//;

print "Job $basename missing msds $_\n"



}

}





brian volk

hpproducts.com

bvolk@xxxxxxxxxxxxxx <mailto:bvolk@xxxxxxxxxxxxxx>

317-298-9950 x1245




.