Skip to content

Instantly share code, notes, and snippets.

@barbie
Created July 28, 2010 07:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barbie/493705 to your computer and use it in GitHub Desktop.
Save barbie/493705 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use List::Util qw(sum);
my %result;
while (<>) {
chomp;
my $line = $_;
my (undef, $topic, @scores) = split /\s*\|\s*/, $line;
next unless $topic;
next if $topic =~ /Questions/;
unshift @scores, 0;
$_ =~ s/-/0/ for @scores;
my $count = sum @scores;
my $total = 0;
for (1 .. 10) {
$total += $scores[ $_ ] * $_;
}
$total /= $count;
print "$topic: $total\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment