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?

Ok, reading it from the bottom up,
</var/script/proc/*>
Makes a list of files in that directory. It's then used as the second argument to
map [$_, -M]
which, from that list, generates a 2nd-order list, each element of which is a list containing in field one the filename, and in field two the modification time (-M is a test operator giving that -- it's default parameter is $_). If you're a C Programmer, think something like the following for each entry in that 2nd order list:
struct { char filename[FNSIZE]; int mtime; /* The date field -- modification time */ }
That structure is then used as an argument to
sort { $a->[1] <=> $b->[1] }
which sorts the first index of the 2nd-order list by the date field. The results are then used as the 2nd argument to
map $_->[0]
which returns a 1d list containing just the filenames (although they're sorted this time). The results are then saved in @newest_first. Code like the above can be intimidating unless you know the map operator well. It's an extremely powerful tool once you do though, and is one of the ways in which Perl's expressiveness borrows from Lisp. Hope this helps.