+our %tiebreak; # $tiebreak{ winningcand }{ losingcand } = 1
+
+while (@ARGV && $ARGV[0] =~ m/[<>]/) {
+ my ($losers, $winners) = ($? eq '<' ? ($`, $') : ($', $`));
+ my @losers = sort split /\,/, $losers;
+ my @winners = sort split /\,/, $winners;
+ die "@losers @winners" if @losers>1 && @winners>1;
+ my @all = sort @losers, @winners;
+ my $record = sub {
+ my ($how, $howers) = @_;
+ return unless @$howers == 1;
+ die "@all $how" if defined $tiebreak{$how}{"@all"};
+ $tiebreak{$how}{"@all"} = $howers->[0];
+ };
+ $record->('winner', \@winners);
+ $record->('loser', \@losers);
+ shift @ARGV;
+}
+