Help on Schwartzian method
am 12.06.2007 18:15:25 von jisHi all,
I was reading through UR coloumns by Randal in www.stonehenge.com. I
came across the code which i really tried heating up my brain ..but
with no result. Can anyone help me understand how the concept goes.
(1)
@data = <>; # read data
foreach (@data) {
($name,$score) = split; # get score
$score{$_} = $score; # record it
}
I guess $_ contains what is read from @data at a given time in
the loop.Am I correct?
(2)
But what is $_ in
@pairs = map {
($name, $score) = split;
[ $_, $score ];
} @data;
Randal says" I build a two-element anonymous list from the $score and
the original value $_"
what does that mean?
(3)
print
map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [$_, (split)[1] ] }
<>;
Now I dont even have any clue on what is $_->[0],$a->[1] and $b-
>[1]
Please help me with answers.
regards,
jis