in reply to sorting files by date and names

This depends on how you're iterating through your files. But under the assumption you've got a list of strings which refer to file names you could do the following
my @sorted_files = sort map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, [stat]->[10] ] } @files;
The main problem with this however is that ctime is not a true indication of the creation of the file (see. this node for more info).
HTH

_________
broquaint

Replies are listed 'Best First'.
Re^2: sorting files by date and names
by Win (Novice) on Mar 20, 2006 at 11:08 UTC
    How would you modify that to sort by creation time and then by modification time?

      Well, [stat]->[10] gives the "creation" time, and the modification time is in 9; so you could do this:

      my @sorted_files = map { $_->[0] } sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } map { [ $_, [stat]->[10], [stat]->[9] ] } @files;

      But for some reason, I'm tempted to do this:

      my @sorted_files = map { $_->[0] } sort { $a->[11] <=> $b->[11] or $a->[10] <=> $b->[10] } map { [ $_, stat ] } @files;
      We're building the house of the future together.