File:  [Local Repository] / processmail / Attic / jointables.pl
Revision 2.1: download - view: text, annotated - select for diffs - revision graph
Mon Jan 24 03:16:35 2005 UTC (19 years, 5 months ago) by boris
Branches: MAIN
CVS tags: HEAD
Added new files

#!/usr/bin/perl
#
# Join tables
#
use strict;
my $USAGE="USAGE: $0 prelim.table final.table\n";
if (scalar(@ARGV) != 2) {
    die $USAGE;
}

my %teams;
open (PRELIM, $ARGV[0]);
while (<PRELIM>) {
    if ($. == 1) {
	next;
    }
    if (/^Рейтинг/) {
	last;
    }
    chomp;
    my ($num, $score, $total, $rating, @team) = split;
    my $team = join(" ",@team);
    $teams{$team}->{score}=$score;
}
close PRELIM;
open (FINAL, $ARGV[1]);
while (<FINAL>) {
    if ($. == 1) {
	next;
    }
    if (/^Рейтинг/) {
	print;
	last;
    }
    chomp;
    my ($num, $score, $total, $rating, @team) = split;
    
}

foreach $team (sort 
	        {
		    $teams{$b}->{score} <=> $teams{$a}->{score}
		    or
			$teams{$b}->{rating} <=> $teams{$a}->{rating}
		} keys %teams
	       )
{
    printf "%5d ",$teams{$team}->{regnum};
    for ($i=1;$i<=$MAXQUEST;$i++)
    {
	my $answer = $teams{$team}->{answers}[$i];
	my $score = $answers[$i]->{$answer}->{score};
	$score = '-' unless $score;
	if ($SHORT) {
	    printf "%1s",$score;
	} else {
	    printf "%3s", $score;
	}
    }
    printf "%3s",$teams{$team}->{score};
    printf "%4s",$teams{$team}->{rating};
    print " $team";
    print "\n";
}

while (<FINAL>) {
    print;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>