in reply to small steps toward Perl literacy, temp vars and parentheses
Whenever i notice map, i generally read the LIST part first followed by reading (BLOCK|EXPR) body, followed by anything before the map.
If any part of the map structure has more than 1 thing going on, i split it over multiple lines. Your example would be shaped like (excessive in this particular case)...
%h = ( map { $_ , $h{$_}; } sort { $a <=> $b } keys %h )[0,1] ;
I am not bothered by the array slice at the end. But as somebody else has/have noted, there is no need to squeeze every little bit of temporary variables at the cost of clarity.
As to reading code w/ parentheses ... my expectation is not to find nested parentheses; otherwise i have to work very hard to keep track of them. In the second case, i tend to indent and split the text on each opening parenthesis before doing anything else.
|
|---|