[! use XMLRPC::Lite; !] [! Execute( 'Golf.epl' ); !] [- $fdat{hole_id} ||= 2; $fdat{course_id} ||= 2; $pgas_url = 'http://perlgolf.sourceforge.net/cgi-bin/PGAS/service'; $aref = XMLRPC::Lite -> proxy($pgas_url) -> call('PGAS.getScoreboard', $fdat{course_id}) -> result; #$_->{rank} .= '(b)' for @{$aref->[1]}; @array = (@{$aref->[0]}, @{$aref->[1]} ); @scores = map $_->{score}, @array; %yindex = Golf::compute_y_index( @scores, map $_->{score},@{$aref->[2]} ); %aprize = Golf::compute_prize( @scores ); %all_stats = Golf::hole_stats( @scores ); %veteran_stats = Golf::hole_stats( map $_->{score}, @{$aref->[0]} ); %beginner_stats = Golf::hole_stats( map $_->{score}, @{$aref->[1]} ); -] [$ sub print_graph $] [- ( $stats, $scores, $title ) = @_; $nbr_steps = 13; $step = ($stats->{ninety_percentile} - $stats->{best}) / $nbr_steps; @histo=(); @histo_label=(); for my $i ( 1..$nbr_steps ) { push @histo_label, int( $stats->{best} + ($i-1)*$step ). "-". int( $stats->{best} + ($i)*$step ); push @histo, 0+grep { ($_>= $stats->{best} + ($i-1)*$step) and ($_ < $stats->{best} + ($i)*$step)} @$scores; } push @histo_label, "over ". int( $stats->{best} + $nbr_steps*$step ); push @histo, 0 + grep $_ >= $stats->{best} + $nbr_steps * $step, @$scores; $max = $histo[0]; $_ > $max and $max = $_ for @histo; $max ||= 1; # just to be safe -]
[$ foreach $i ( @histo ) $] [$ endforeach $] [$ foreach $i ( @histo_label ) $] [$ endforeach $]
[+ $i  +]
[+ $i +]
[+ $title +]
[$ endsub $] Perl Golf
[- $courses = XMLRPC::Lite->proxy($pgas_url)->call('PGAS.getAllCourses')->result; # find the right course /and/ hole ($course) = grep $_->{id} == $fdat{course_id}, @$courses; ($hole) = grep $_->{id} == $fdat{hole_id}, @{$course->{holes}}; -]

[+ $course->{name}+]

[+gmtime( $course->{start} ) +]- [+gmtime( $course->{end} )+] [$ if $course->{end} > time() $]     in progress [$ endif $]

AllVeteransBeginners
Mean: [+ $all_stats{ mean } +] [+ $veteran_stats{ mean } +] [+ $beginner_stats{ mean } +]
Median: [+ $all_stats{ median } +] [+ $veteran_stats{ median } +] [+ $beginner_stats{ median } +]
Best score: [+ $all_stats{ best } +] [+ $veteran_stats{ best } +] [+ $beginner_stats{ best } +]
Worst score: [+ $all_stats{ worst } +] [+ $veteran_stats{ worst } +] [+ $beginner_stats{ worst } +]
10th percentile: [+ $all_stats{ tenth_percentile } +] [+ $veteran_stats{ tenth_percentile} +] [+ $beginner_stats{ tenth_percentile } +]
90th percentile: [+ $all_stats{ ninety_percentile } +] [+ $veteran_stats{ ninety_percentile} +] [+ $beginner_stats{ ninety_percentile } +]
Standard deviation: [+ $all_stats{ std_dev } +] [+ $veteran_stats{ std_dev} +] [+ $beginner_stats{ std_dev } +]
Number of Entries: [+ $all_stats{ entries } +] [+ $veteran_stats{ entries } +] [+ $beginner_stats{ entries } +]

Scores Distribution

[- print_graph( \%all_stats, \@scores, 'all entries' ) -] [- print_graph( \%veteran_stats, [map $_->{score}, @{$aref->[0]}] , 'veterans' ) -] [- print_graph( \%beginner_stats, [map $_->{score}, @{$aref->[1]}] , 'beginners' ) -]

Veteran Scoreboard

[$ foreach $g (@{$aref->[0]}) $] [$ endforeach $]
rank golfer score Y-index A-prize
[+ $g->{rank} +] [+ $g->{golfer} +] [+ $g->{score} +] [+ $yindex{$g->{score}} +] [+ $aprize{$g->{score}} +]

Beginner Scoreboard

[$ foreach $g (@{$aref->[1]}) $] [$ endforeach $]
rank golfer score Y-index A-prize
[+ $g->{rank} +] [+ $g->{golfer} +] [+ $g->{score} +] [+ $yindex{$g->{score}} +] [+ $aprize{$g->{score}} +]

Team Scoreboard

[$ foreach $g (@{$aref->[2]}) $] [$ endforeach $]
rank team score Y-index
[+ $g->{rank} +] [+ $g->{golfer} +] [+ $g->{score} +] [+ $yindex{$g->{score}} +]

hacked by Yanick Champoux