in reply to Re^2: small steps toward Perl literacy, temp vars and parentheses
in thread small steps toward Perl literacy, temp vars and parentheses

I guess we read the code in different ways. I don't think of the code as a list of operations applied to %h, but as assigning the results of map to %h.

map takes a list and manipulates it. The fact that the input to map is also derived from %h is effectively moot. It could equally well be a completely different hash.

I look at

%h = map{ $_, $h{ $_ } } ( sort{ $a <=> $b } keys %h )[ 0 .. 2 ];

as: Take the first 3 from a list of sorted keys and feed them to map. Map those keys to key/value pairs and assign them to %h.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
"Memory, processor, disk in that order on the hardware side. Algorithm, algoritm, algorithm on the code side." - tachyon