in reply to How to list files in dir with respect to time ?

You can get mtime as the tenth element of the list returned by stat. Here's a quick way to do it,

my @files_by_mtime = map {$_->[0]} sort {$a->[1] <=> $b->[1]} map {[$_,(stat)[9]]} glob "$dir/*";

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: How to list files in dir with respect to time ?
by salva (Canon) on Aug 16, 2005 at 09:53 UTC
    or even easier (and faster) with Sort::Key:
    use Sort::Key qw(nkeysort); my @files_by_mtime = nkeysort { (stat)[9] } glob "$dir/*";