#!perl -F',' use strict; use warnings; use feature 'state'; state $header = 1; our @sums; if ($header) { printf "%-24s" . " %4s"x10, 'Number', @F[1..10]; $header = 0; next; } chomp $F[10]; for (reverse 2..10) { $F[$_] = ( ( $F[$_-1] xor $F[$_] ) ? .5 : 0 ); $sums[$_] += $F[$_]; } $F[1] = 0; $sums[1] += $F[1]; printf "%-24s " . " %3.1f "x10 . "\n", @F; END{ our @sums; printf '*'x75 . "\n"; printf "%-24s" . " %3.1f "x10 . "\n", "Sum of weights", @sums[1..10]; printf '*'x75 . "\n"; }