my ($oldest) = map { $_->[0] } sort { $b->[1] <=> $a->[1] } map { [ $_, -M $_ ] } <*>;
The above isn't very memory-efficient, but is probably as quick as you can hope for. Change -M with -A or -C if necessary (see relevent Perl doc). Might also want to check that the file is not a directory. The <*> might have to be changed to get a directory other than the current one.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
In reply to Re: Quickest way to get the oldest file
by hardburn
in thread Quickest way to get the oldest file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |