Stefan,

The 'Schwartzian Transform' usually is a good approach for such cases. It is
not very difficult as it seems to be (Thanks to http://5sigma.com of Joseph
Hall). Please follow the comments and it should be pretty straightforward:

Cheers,
Rex


#!/usr/bin/perl
use strict;
my(@listOfFiles) = <*>;
#Using Schwartzian Transform (Read from Bottom-to-top)
#a) Get the file names and its modification date
#b) Sort the files based on -M (Age of files since script started).
# This will put the latest files to the top of the stack
#c) Slash the contents to @sortedFiles array
my(@sortedFiles) = map{[$_->[0], $_->[1]]}
      sort{$a->[1] <=> $b->[1]}
      map {[$_,-M $_]}
      @listOfFiles;
foreach(@sortedFiles){
 print "$_->[0]\t\t=> $_->[1]\n";
}


----- Original Message -----
From: "Dolfen, Stefan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, October 29, 2001 3:16 AM
Subject: newbie : how to find the latest file in a directory


> Hello,
>
> how can I find the latest file in a directory ?
>
> thanks,
> Stefan
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to