in reply to map grep and sort
It is also worth mentioning, perhaps as a counterpoint to this most-excellent thread (that I just dropped a great many up-votes onto) ... whatever you do, be clear, and always code for the future. Chains of map/sort/grep can indeed be quite powerful, but they can also be ... or, over time, can become ... difficult to maintain. If what you are doing can alternatively be expressed using, say, one of the List::Util packages, and even when a peek under the covers of those modules reveals heavy use of map/sort/grep, consider carefully what approach is best to take. (I do not mean to suggest the answer.)
Probably for many years in the future, someone (else ... sucks that that bread-truck was in same place you were at the same time) is going to encounter that code, is going to have to accurately understand it, and is going to have to make what may well be a significant change, thanks to the ever-present Marketing Department. It will be critical for them to be able to make the right changes to your “elegant” logic, which can be very difficult. Perhaps the change that they must do will prove to be quite disruptive to your original design choice ... whereas, given a different choice on your part, it would not have been so. Carefully weigh these concerns against elegance and efficiency. You are creating logic that is “very tightly coupled.” Every step in the chain must be considered together and is co-dependent upon every other part of it. Aye, this is both a fee-chur and a curse.
Make sure that you subject this sort of logic to extensive testing, e.g. with the ubiquitous Test::More, and that you ... well ... that you do actually test it thoroughly. Precisely because these techniques do pack a lot of semantic meaning into a very small space, it becomes exceptionally easy to make an unintended error. CPAN modules already include extensive self-tests that are run at installation time. Your logic, initially, has none. Many times, a subtle application problem can be traced to an edge-case that encountered elegance. Now, the solution was obliged to be a “big and tricky” rewrite of a tightly-interconnected (but elegant!) section of code.