in reply to small steps toward Perl literacy, temp vars and parentheses
Do you find it more readable? Personally, I found the line breaks and indentation that other posters provided was more helpful in adding readability than making the direction consistent. But if you're going to do it on one line, it is helpful to have things go one direction.%h = map { $_->[0], $h{$_->[0]} } [ sort { $a<=>$b } keys %h ];
Update: is this better or worse?
Take the keys, sort them, take the first one, and make the hash from the hash entry.%h = map { $_, $h{$_} } map { $_->[0] } [ sort { $a<=>$b } keys %h ];
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: small steps toward Perl literacy, temp vars and parentheses
by rir (Vicar) on Jun 17, 2004 at 20:51 UTC |