in reply to small steps toward Perl literacy, temp vars and parentheses
my @temp = map { $_ => $h{$_} } sort { $a <=> $b } keys %h; %h = @temp[0,1];
This tells me I'm doing something with %h, then I'm reassigning that result back to %h; Of course, I could use a do statement, as so:
%h = do { my @temp = map { $_ => $h{$_} } sort { $a <=> $b } keys %h; @temp[0,1]; };
That's nicer, but I don't like having my chained operators so far from the left margin. While I limit myself to 80 columns, I like to keep it, if at all possible, in under 40.
%h = do { my @temp = map { $_ => $h{$_} } sort { $a <=> $b } keys %h; @temp[0,1] };
That's how I write my LisPerl, with the chains listed vertically instead of horizontally.
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
|
|---|