#!/usr/local/bin/perl eval "exec /usr/local/bin/perl -S $0 $*" if $running_under_some_shell; # this emulates #! processing on NIH machines. # (remove #! line above if indigestible) eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_]+=)(.*)/ && shift; # process any FOO=bar switches $[ = 1; # set array base to 1 $row = 1; while (<>) { @Fld = split(' ', $_, 9999); if (/^.-./) { for ($i = 1; $i <= 6; $i++) { $r{$row} += $Fld[2 * $i]; $c{$i} += $Fld[2 * $i]; $total += $Fld[2 * $i]; if ($row == $i) { #??? $d += $Fld[2 * $i]; $double{$i} += $Fld[2 * $i]; } } $row++; if ($row > 6) { $row = 1; } } } &print_current(); sub print_current { $expected = ($total / 6 ); printf("\n====== Raw data ======\n\n"); printf "Total rolls: %d\n Total/6: %d\n", $total, $expected; printf(" Doubles: %d\n\n", $d); printf("1-x 2-x...\nx-1 x-2...\n"); printf("----------\n"); for ($i = 1; $i <= 6; $i++) { printf("%d ", $c{$i}); } printf ("\n"); for ($i = 1; $i <= 6; $i++) { printf("%d ", $r{$i}); } printf ("\n\nNumber totals expect %2.3f\n------ ------\n", 100/3); for ($i = 1; $i <= 6; $i++) { $temp_ttl = $r{$i} + $c{$i} ; printf("%d %d %2.3f\n",$i, $temp_ttl, $temp_ttl * 100 / $total); } printf ("\n\n\n"); printf("====== Sorted data ======\n\n"); for ($i = 0; $i < 6; $i++) { $data_array{2 * $i} = $c{$i + 1}; $data_array{(2 * $i) + 1} = $r{$i + 1}; } @data = values %data_array; @data = sort {$a <=> $b} @data; printf("Total Diff Percentage\n"); printf("----- ---- ----------\n"); for ($i = 1; $i < 13; $i++) { printf "%d %d %2.3f\n", $data[$i], $data[$i] - $expected, $data[$i] * 100.0 / $total; } printf "%d %d %2.3f <== doubles\n", $d, $d-$expected, $d * 100 / $total; }