Commit e14637d2 authored by Robert Ricci's avatar Robert Ricci

Add support for fractional points

So far, only in the points received, not the points possible; seems
unlikely I'll do fractional points for the latter
parent addcf575
......@@ -12,7 +12,7 @@ foreach my $line (<SCORE>) {
if ($scoreline) {
die "ERROR: Found two score lines!\n";
}
if (! ($line =~ /\d+\s*\/\s*\d+/)) {
if (! ($line =~ /\d+(\.\d+)?\s*\/\s*\d+/)) {
die "ERROR: Score is not numeric - error in run total-score?\n";
}
$scoreline = $line;
......
......@@ -12,8 +12,8 @@ my $total_possible = 0;
my $found_totalline = 0;
foreach my $line (@scorefile) {
if ($line =~ /^\s*(\d+|XX)(\s*\/\s*(\d+)\s*)?/) {
my ($score, $possible) = ($1, $3);
if ($line =~ /^\s*(\d+(\.\d+)?|XX)(\s*\/\s*(\d+)\s*)?/) {
my ($score, $possible) = ($1, $4);
if ($score eq "XX") {
die "Score not filled on line: $line\n";
} else {
......@@ -22,7 +22,7 @@ foreach my $line (@scorefile) {
if ($possible) {
$total_possible += $possible;
}
} elsif ($line =~ /^\s*Total score:\s*(XX|\d+)?\s*\/\s*(YY|\d+)?/) {
} elsif ($line =~ /^\s*Total score:\s*(XX|(\d+(\.\d+)?))?\s*\/\s*(YY|\d+)?/) {
$found_totalline = 1;
$line = "Total score: $total / $total_possible\n";
print $line;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment