chiark / gitweb /
normal2openstvtxt: produces something that openstv accepts; need to check
[appendix-a6.git] / normal2openstvtxt
1 #!/usr/bin/perl -w
2
3 for (;;) {
4     $_ = <>;
5     if (m/^\| /) {
6         if (s/ _?[Ss]eats=(\d+)\s/ /) {
7             print STDERR "# openstv-run-election -s $1\n";
8         }
9         die if m/ [A-Z]/;
10         warn if m/ [a-z]/;
11     } elsif (s/^\w+ = [^|]+ \|//) {
12         die if m/ [A-Z]/;
13         warn if m/ [a-z]/;
14     } elsif (s/^\w+ \: ([^|]*) \|//) {
15         print $1,"\n" or die $! if length $1;
16         die if m/ [A-Z]/;
17         warn if m/ [a-z]/;
18     } elsif (m/^\.$/) {
19         last;
20     } else {
21         die;
22     }
23 }