#!/usr/bin/perl -w # Copyright (c) 2005-2006 Jonathan Lundell; All Rights Reserved. # # IMPORTANT: This software is supplied to you by Jonathan # Lundell ("Jonathan") in consideration of your agreement to # the following terms, and your use, installation, # modification or redistribution of this software # constitutes acceptance of these terms. If you do not # agree with these terms, please do not use, install, # modify or redistribute this software. # # In consideration of your agreement to abide by the # following terms, and subject to these terms, Jonathan grants # you a personal, non-exclusive license to use, reproduce, # modify and redistribute this software, with or without # modifications, in source and/or binary forms; provided # that if you redistribute the software with # modifications, you must remove this copyright notice and # the following text and disclaimers in all such # redistributions. The name Jonathan Lundell and/or this # product may not be used to endorse or promote products # derived from this software without specific prior # written permission from Jonathan. Except as expressly stated # in this notice, no other rights or licenses, express or # implied, are granted by Jonathan herein, including but not # limited to any patent rights that may be infringed by # your derivative works or by other works in which the # software may be incorporated. # # This software is provided by Jonathan on an "AS IS" basis. # JONATHAN MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING # WITHOUT LIMITATION THE IMPLIED WARRANTIES OF # NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A # PARTICULAR PURPOSE, REGARDING THE SOFTWARE OR ITS USE # AND OPERATION ALONE OR IN COMBINATION WITH YOUR # PRODUCTS. # # IN NO EVENT SHALL JONATHAN BE LIABLE FOR ANY SPECIAL, # INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR # PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY # OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR # DISTRIBUTION OF THE SOFTWARE, HOWEVER CAUSED AND WHETHER # UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), # STRICT LIABILITY OR OTHERWISE, EVEN IF JONATHAN HAS BEEN # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use strict; use FindBin; # where was script installed? use lib $FindBin::Bin; # use that dir for libs, too use STV; # stv-counter.pl Simple driver for STV.pm # my ($ballotfile, $resultsfile) = @ARGV; my $rv = countSTV($ballotfile, $resultsfile, VERBOSE_DETAILS); print "CALLER: nballots=$STV::nballots\n";# Summarize results. if (defined($STV::fatalmsg)) { print "FATAL: $STV::fatalmsg\n"; exit(1); } if (!defined($rv)) { print "FATAL: unknown error\n"; exit(1); } foreach my $warning ( @STV::warnings ) { print "WARNING: $warning\n"; } print "\nResults:\n"; my $nick; foreach $nick ( keys %STV::cName ) { # for each candidate next if ( !$STV::cElected{$nick} ); print "Elected: " . $STV::cName{$nick} . " (approval=" . $STV::cApproval{$nick} . ")\n"; } foreach $nick ( keys %STV::cName ) { # for each candidate next if ( !$STV::cHopeful{$nick} ); print "Hopeful: " . $STV::cName{$nick} . " (approval=" . $STV::cApproval{$nick} . ")\n"; } foreach $nick ( keys %STV::cName ) { # for each candidate next if ( $STV::cHopeful{$nick} || $STV::cElected{$nick} || $STV::cWithdrawn{$nick} || $STV::cRetired{$nick} ); print "Eliminated: " . $STV::cName{$nick} . " (approval=" . $STV::cApproval{$nick} . ")\n"; } foreach $nick ( keys %STV::cName ) { # for each candidate next if ( !$STV::cRetired{$nick} ); print "Retired: " . $STV::cName{$nick} . " (approval=" . $STV::cApproval{$nick} . ")\n"; } foreach $nick ( keys %STV::cName ) { # for each candidate next if ( !$STV::cWithdrawn{$nick} ); print "Withdrawn: " . $STV::cName{$nick} . " (approval=" . $STV::cApproval{$nick} . ")\n"; }