in reply to Quickest way to get the oldest file
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re:x2 Quickest way to get the oldest file (don't sort)
by grinder (Bishop) on Jan 20, 2004 at 08:24 UTC |