in reply to Sort files descending by date

If the files names are the same length and format (as would appear from your example data), I'd use a substr approach such as posted by ikegami.

If there is a possibility of the format of the filenames changing, I'd use somthing like:

my @sorted_list = map { $_ -> [1] } sort { $a->[0] cmp $b->[0] } map { [ do { (my $x = $_) =~ tr/0-9//dc; $x }, $_ ] } @file_list;

However, having written it, I'm not particularly proud of using a do{} within a map.

Replies are listed 'Best First'.
Re^2: Sort files descending by date
by ikegami (Patriarch) on Jun 19, 2007 at 18:08 UTC

    I'm not particularly proud of using a do{} within a map.

    Then don't do it :)

    map { (my $ts = $_) =~ tr/0-9//dc; [ $ts, $_ ] }, @file_list;
      Yes, that's much better. Thank you.