#!/usr/bin/perl -wn use strict; # @title = qw(A B C D); my ($sum, $full, @g, $i, $class_full); my (@day_full) = qw(30 2 30 30 30 30 30 30 30); my (@night_full) = qw(30 30 2 30 30 30 30 30 30 30 30); chomp; last if /^###.*###/; my ($id, $name, $g1, $warn, $g2, $bonus) = split /:/; unless (defined $g2 and $id =~ /^\w+\s*$/ and (@g = split " ", "$g1 $g2") and ($#g == $#day_full or $#g == $#night_full) ) { print "$_\n"; next; } # 計算平時成績 $sum = $full = 0.0; $class_full = $#g == $#day_full ? \@day_full : \@night_full; for ($i=0; $i<=$#g; ++$i) { next if not $g[$i] =~ /^\d+$/; $sum += $g[$i]; $full += $class_full->[$i]; } $sum *= 80.0 / $full; $sum += $bonus if $bonus =~ /\d/; ### 期中預警 # $warn = ($sum >= 50) ? "OK" : # ($sum >= 35) ? "C" : # ($sum >= 30) ? "D" : "E"; ### my ($exam_type) = $sum >= 39 ? "末" : "補"; printf "$id:$name:$g1:$warn:$g2:$bonus: %4.1f : $exam_type\n", $sum;