#!/usr/bin/perl -w
+#
+# usage:
+# normalise [NORM-OPTIONS...] [--] INPUT-FILES...
+#
+# NORM-OPTIONS are
+# +OPTNAME[=OPTVAL] Election option
+# CAND=[DESCRIPTION]
+# +CAND+OPTNAME[=OPTVAL] Candidate option
+# -- End of options to normalise
+# -... Reserved for future options to normalise
use strict;
our @ballots;
my $candvoter_re = '\w+';
+my $opt_re = '\w+(?:=\S*)?';
sub badinput ($) {
die "bad input: $_[0]";
}
}
+while (@ARGV) {
+ $_ = shift @ARGV;
+ if (m/^--$/) {
+ last;
+ } elsif (m/^(\w+)=([^|]+)$/) {
+ setcanddesc $1, $2;
+ } elsif (m/^\+($opt_re)$/) {
+ push @options, $1;
+ } elsif (m/^\+(\w+)\+($opt_re)$/) {
+ push @{ $candidates{$1}{Opts} }, $2;
+ } elsif (m/^-/) {
+ die "unknown normalise option \`$_'\n";
+ } else {
+ # oh!
+ unshift @ARGV, $_;
+ last;
+ }
+}
+
while (<>) {
next unless m/\S/;
next if m/^\#/;