in reply to Re: •Re: Keeping only the $n newest files/directories in a diretory?
in thread Keeping only the $n newest files/directories in a diretory?
The simplest case would be to do a single line sort:
my @newest_first = sort { -M $a <=> -M $b } </var/script/proc/*>;
However, to sort, one must compare pairs of items, often comparing the same $a to many different $bs, and vice versa. All those -M checks take a lot of time.
Read a Schwartzian Transform like this starting with the last line.
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: •Re: Keeping only the $n newest files/directories in a diretory?
by Juerd (Abbot) on Apr 19, 2003 at 13:11 UTC |