Trevor Goddard wrote:
> I want to be able to
>
> my $loc_src_dir = "g:\\inputdir\\";
> my @files = glob("$loc_src_dir*.txt");
>
> but only get the first 10 files sorted by creation date.
>
> I have had a look at the glob() and File::Glob() documentation but they
> don't seem to give me what I want.
If you want the files sorted by date, I would use opendir/readdir or
File::Find and stat each file after filtering the none .txt files.
I hate globbing, but you could glob the .txt files into an array and
then stat each ctime/mtime into a hash for sorting by value.
my $dir = './data';
my @files = <$dir/*.prev>;
my %files = ();
# create a hash filename => ctime
$files{$_} = (stat $_)[10] foreach @files;
# sort by ctime and print filenames
print "$_\n" foreach sort { $files{$a} <=> $files{$b} } keys %files;
--
,-/- __ _ _ $Bill Luebkert Mailto:[EMAIL PROTECTED]
(_/ / ) // // DBE Collectibles Mailto:[EMAIL PROTECTED]
/ ) /--< o // // Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_ http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs