in reply to Re^2: how to list the files in dir with respect to time
in thread how to list the files in dir with respect to time

The map reduces the number of stat calls by half. Compare to:

use List::Util 'reduce'; my $newest = reduce { (stat $a)[9] < (stat $b)[9] ? $b : $a } glob '/path/to/*.log';

It's not possible to use the *_ handle for a cached stat call there, because we don't know that the currently reduced name was the subject of the most recent stat call.

Your hash approach is fine, too, but it would also benefit from reduce() over sort.

After Compline,
Zaxo