chiark / gitweb /
compute-scottish-stv: sort countballots output
[appendix-a6.git] / stv
diff --git a/stv b/stv
index 68940f452683825259efcecc5fdc2fffbb7c3a38..3c6160e979f27ffa7f026ed59d20a4b2dabf2710 100755 (executable)
--- a/stv
+++ b/stv
@@ -3,6 +3,19 @@
 # Does STV according to
 #  http://www.rosenstiel.co.uk/stvrules/av/index.htm
 
+# Usage:
+#  ./stv [TIEBREAK ...] PLACES [INPUT-FILES ...]
+#
+# PLACES is the number of seats to be filled
+#
+# INPUT-FILES are in the format:
+#    VOTER PQRST
+# where P, Q, R, etc. are candidates.  Candidates
+# must be single letters.
+#
+# Each TIEBREAK is
+#   P,Q,... 
+
 use strict;
 use utf8;
 use autodie;
@@ -398,4 +411,14 @@ for (;;) {
     push @unsorted, @$votes;
 }
 
+open VL, ">.stv.votes" or die $!;
+foreach my $vote (@allvotes) {
+    print VL "----------------------------------------\n";
+    print VL "voter $vote->{Voter}\n";
+    print VL "prefs ". (join " ", @{ $vote->{Prefs} }). "\n";
+    print VL $_, "\n" foreach @{ $vote->{Log} };
+}
+print VL "========================================\n";
+close VL;
+
 print "done.\n";