You could sort by mtime from stat or, better, apply List::Util::reduce() to the filename list. We'll insert a Schwartzian Transform-like mapping to reduce the number of stat calls.
use List::Util 'reduce'; my $newest = ( reduce { $a->[1] < $b->[1] ? $b : $a } map { [ $_, (stat)[9] ] } glob '/path/to/*.log' )->[0];
After Compline,
Zaxo
In reply to Re: how to list the files in dir with respect to time
by Zaxo
in thread how to list the files in dir with respect to time
by swaroop
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |