This is a line I pulled out of a program on PerlMonks to find the largest 10 files in a directory. The program is clear enough, I suppose, but I don't understand the following line:
@sizes = grep {length $_ -> [1]} @sizes;
Specifically, what is
{length $_ -> [1]}
doing? It seems to be sorting files by length but I don't understand the mechanism. Anyone care to elucidate?
I saw Windtalkers on DVD tonight. Lots of action, lots of explosions; I think Joe Bob Briggs would give it a thumbs up. I liked it and believe it is worth your time.
Thanks to merlyn and ybiC for their replies to my last entry. As a matter of fact I have a copy of Learning Perl. Unfortunately it is packed in one of dozens of boxes as part of our coming move. I am loathe to buy another copy of a book I already have. However, since I don't yet have a copy of Elements of Programming with Perl I plan to buy that. Scrooge McDuck ain't in it with me when it comes to pinching pennies.
I am going to learn Perl. As long it takes, whatever it takes, but learn it I will. A short attention span, dog-laziness, carelessness past comprehension and a thick head will not stop me.
grep-foo (Score:2)
From the docs:
The most basic example is something like:
This goes though the list (1,
--
"Cake or Death!"
Re:grep-foo (Score:1)
Oh. Ow. Ouch! @size is not an array of file names but rather a line with file name, file size, etc. I might plead that I am a windows programmer but geez, even so, I should have realized that. My stumbling block was [1]. I couldn't see the relationship even knowing what -> was. Density^3. Thank you.
where's the rest of the code? (Score:1)
Re:where's the rest of the code? (Score:1)
Certainly. This was written by Abigail-II in answer the question Finding Top 10 Largest Files on PerlMonks. Since Abigail-II wrote it I have no doubt as to the correctness of the program:
Re:where's the rest of the code? (Score:3, Informative)