-----Original Message-----
From: Bob Showalter [mailto:[EMAIL PROTECTED]
Sent: Monday, December 12, 2005 4:44 PM
To: Brian Volk
Cc: '[email protected]'
Subject: Re: sort files by creation time
Brian Volk wrote:
> 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.
This will load @ARGV with the files in the current directory sorted
oldest -> newest:
@ARGV = map $_->[0],
sort { $b->[1] <=> $a->[1] }
map [ $_, -M ],
grep -f, # get only plain files
<*>;
How it works is left as an exercise for the reader :-)
Thank you! And I think I just bought the book that explains the above!
Alpaca! Soon to find out!
Thanks again.
Brian Volk
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>