in reply to how to list the files in dir with respect to time
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to list the files in dir with respect to time
by graff (Chancellor) on Aug 02, 2005 at 03:18 UTC | |
by Zaxo (Archbishop) on Aug 02, 2005 at 03:36 UTC | |
by sk (Curate) on Aug 02, 2005 at 03:40 UTC | |
by graff (Chancellor) on Aug 02, 2005 at 03:44 UTC | |
by sk (Curate) on Aug 02, 2005 at 03:46 UTC | |
|
Re^2: how to list the files in dir with respect to time
by xdg (Monsignor) on Aug 02, 2005 at 11:29 UTC |