in reply to small steps toward Perl literacy, temp vars and parentheses
In the second bit of code there is a lot of contextual info to tell one to jump to
I've learned to stop worrying about this and enjoy writing LISP in Perl :)
Removing my tounge from my cheek, I think people shouldn't expect Perl to just be interpreted C. People who have a strong C background may have problems reading chained operations like that, but it's standard operating procedure in LISP and other functional languages. So when somebody tells you that the code you shown above is sloppy, you'll know which community they come from.
Now, I think you are correct to say that the index isn't a very pleasing way to end the statement. Maybe this will do it (untested):
%h = @{ shift ( map {[ $_, $h{$_} ]} sort { $a<=>$b } keys %h)};
Of course, now you have to explain to The Complainer the difference between lists and arrays.
----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: small steps toward Perl literacy, temp vars and parentheses
by BlaisePascal (Monk) on Jun 16, 2004 at 21:54 UTC | |
by Jenda (Abbot) on Jun 16, 2004 at 22:18 UTC | |
by ysth (Canon) on Jun 23, 2004 at 08:14 UTC | |
by dragonchild (Archbishop) on Jun 17, 2004 at 03:07 UTC |