wrote:
> All,
>
> I am trying to glob a directory, storing the filenames into an array.
> The trick is that I then want to sort that array by the files'
> timestamps. Is there an easy way to do this?
>
> TIA!
For example (UNTESTED):
my $dir = 'something';
opendir my $DH, $dir or die "Cannot opendir '$dir' $!";
my @sorted_files =
map $_->[1],
sort { $a->[0] <=> $b->[0] }
map -f "$dir/$_" ? [ ( stat _ )[9], $_ ] : (),
readdir $DH;
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall