7 binmode STDIN, 'encoding(UTF-8)' or die;
8 binmode STDOUT, 'encoding(UTF-8)' or die;
9 binmode STDERR, 'encoding(UTF-8)' or die;
17 my $choname = shift @_;
18 my $cho = $choices{$choname} = { @_, Index => (scalar @choices) };
19 push @choices, $choname;
27 if (m/^([A-Z]+)\s*\=\s*(\S.*)$/) {
28 my ($choname, $desc) = ($1,$2);
29 my $cho = addchoice($choname, Desc => $desc);
30 if ($desc =~ m/\[(\d+):(\d+)\]/) {
31 $cho->{Smaj} = [$1,$2];
32 } elsif ($desc =~ m/\[default\]/) {
35 } elsif (m/^V:\s+(\S+)\s+(\S.*)/) {
36 push @invotes, [ $1, $2 ];
42 $defcho ||= $choices{FD};
44 $defcho = addchoice('FD', Desc => "Further Discussion");
46 my $defi = $defcho->{Index};
47 die "FD has smaj?!" if $defcho->{Smaj};
49 our @vab; # $vab[$ia][$ib] = V(A,B)
51 foreach my $iv (@invotes) {
52 my ($votestr,$voter) = @$iv;
54 length $votestr eq @choices or die "wrong vote vector length";
55 my @vs = split //, $votestr;
56 foreach my $ix (0..$#vs) {
60 } elsif ($vchr =~ m/[0-9a-z]/) {
61 $vs[$ix] = ord($vchr);
66 foreach my $ia (0..$#vs) {
67 foreach my $ib ($ia+1..$#vs) {
70 if ($va < $vb) { $vab[$ia][$ib]++; }
71 elsif ($vb < $va) { $vab[$ib][$ia]++; }
76 die "voter $voter $@" if $@;
79 foreach my $iy (-2..$#choices) {
80 foreach my $ix (-2..$#choices) {
85 printf "------" or die;
89 } elsif ($ix==-2 && $iy==-2) {
90 printf "V(Y,X)" or die;
92 printf "%5s ", $choices[$ix] or die $!;
94 printf "%5s ", $choices[$iy] or die $!;
96 my $v = \( $vab[$iy][$ix] );
99 printf "%5d ", $$v or die $!;
101 printf "%5s ", "" or die $!;
105 printf "\n" or die $!;