Help on Schwartzian method

Hi 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)

[at] data = <>; # read data
foreach ( [at] data) {
($name,$score) = split; # get score
$score{$_} = $score; # record it
}

I guess $_ contains what is read from [at] data at a given time in
the loop.Am I correct?

(2)
But what is $_ in

[at] pairs = map {
($name, $score) = split;
[ $_, $score ];
} [at] 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
jis [ Di, 12 Juni 2007 18:15 ] [ ID #1736188 ]
Perl » comp.lang.perl.modules » Help on Schwartzian method

Vorheriges Thema: Schwartzian method
Nächstes Thema: Locale::PO seeks new maintainer