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

    1: #!/usr/bin/perl
    2: #
    3: # Join tables
    4: #
    5: use strict;
    6: my $USAGE="USAGE: $0 prelim.table final.table\n";
    7: if (scalar(@ARGV) != 2) {
    8:     die $USAGE;
    9: }
   10: 
   11: my %teams;
   12: open (PRELIM, $ARGV[0]);
   13: while (<PRELIM>) {
   14:     if ($. == 1) {
   15: 	next;
   16:     }
   17:     if (/^Рейтинг/) {
   18: 	last;
   19:     }
   20:     chomp;
   21:     my ($num, $score, $total, $rating, @team) = split;
   22:     my $team = join(" ",@team);
   23:     $teams{$team}->{score}=$score;
   24: }
   25: close PRELIM;
   26: open (FINAL, $ARGV[1]);
   27: while (<FINAL>) {
   28:     if ($. == 1) {
   29: 	next;
   30:     }
   31:     if (/^Рейтинг/) {
   32: 	print;
   33: 	last;
   34:     }
   35:     chomp;
   36:     my ($num, $score, $total, $rating, @team) = split;
   37:     
   38: }
   39: 
   40: foreach $team (sort 
   41: 	        {
   42: 		    $teams{$b}->{score} <=> $teams{$a}->{score}
   43: 		    or
   44: 			$teams{$b}->{rating} <=> $teams{$a}->{rating}
   45: 		} keys %teams
   46: 	       )
   47: {
   48:     printf "%5d ",$teams{$team}->{regnum};
   49:     for ($i=1;$i<=$MAXQUEST;$i++)
   50:     {
   51: 	my $answer = $teams{$team}->{answers}[$i];
   52: 	my $score = $answers[$i]->{$answer}->{score};
   53: 	$score = '-' unless $score;
   54: 	if ($SHORT) {
   55: 	    printf "%1s",$score;
   56: 	} else {
   57: 	    printf "%3s", $score;
   58: 	}
   59:     }
   60:     printf "%3s",$teams{$team}->{score};
   61:     printf "%4s",$teams{$team}->{rating};
   62:     print " $team";
   63:     print "\n";
   64: }
   65: 
   66: while (<FINAL>) {
   67:     print;
   68: }

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