Re: A simple way to detect which files are newer

2009-01-12 Thread Harry Putnam
"Chas. Owens" writes: >> Or do I have to analyze each file with stat or something? > snip > > In the end, someone has to stat each file, but you should be able to > get what you want like this: > > my @files = > map { $_->[1] } > sort { $b->[0] <=> $a->[0] } > map { -f $_ ? [-M _, $_]

Re: A simple way to detect which files are newer

2009-01-12 Thread Gunnar Hjalmarsson
Chas. Owens wrote: Gunnar Hjalmarsson wrote: Harry Putnam wrote: I want to do something like this but with perl: rm -f $(ls -lt|sed -n '6,$p') so that the five newest files are always left. Is there some short way to get that effect in perl? Or do I have to analyze each file with stat or so

Re: A simple way to detect which files are newer

2009-01-12 Thread Chas. Owens
On Mon, Jan 12, 2009 at 17:41, Gunnar Hjalmarsson wrote: > Harry Putnam wrote: >> >> I want to do something like this but with perl: >> >> rm -f $(ls -lt|sed -n '6,$p') >> >> so that the five newest files are always left. >> >> Is there some short way to get that effect in perl? >> >> Or do I have

Re: A simple way to detect which files are newer

2009-01-12 Thread Gunnar Hjalmarsson
Harry Putnam wrote: I want to do something like this but with perl: rm -f $(ls -lt|sed -n '6,$p') so that the five newest files are always left. Is there some short way to get that effect in perl? Or do I have to analyze each file with stat or something? Assuming that you are on a *nix plat

Re: A simple way to detect which files are newer

2009-01-12 Thread Chas. Owens
On Mon, Jan 12, 2009 at 16:59, Harry Putnam wrote: > I want to do something like this but with perl: > > rm -f $(ls -lt|sed -n '6,$p') > > so that the five newest files are always left. > > Is there some short way to get that effect in perl? > > Or do I have to analyze each file with stat or somet

A simple way to detect which files are newer

2009-01-12 Thread Harry Putnam
I want to do something like this but with perl: rm -f $(ls -lt|sed -n '6,$p') so that the five newest files are always left. Is there some short way to get that effect in perl? Or do I have to analyze each file with stat or something? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org