#!/usr/local/bin/perl
#
#$Id: collection.pl,v 1.3 2005/01/24 03:16:35 boris Exp $
#
# Собрание сочинений
#
    use Getopt::Std; 

$usage = 'collection.pl $Revision: 1.3 $, $Date: 2005/01/24 03:16:35 $'. "\n".
"Usage: collection.pl [-d] [-t table_file] [-m mail_file] [-o results] \n";

require 'parameters.pl';
require 'subroutines.pl';

die $usage unless getopts('t:m:o:d');

$DEBUG=$opt_d;



my %teams;
my @answers;
#
# Читаем старые результаты
#
if ($opt_t)
{
    die "Cannot open $opt_t\n" unless open(INFILE,$opt_t);
    readhash(\@answers);
    close(INFILE);
}

#
# Читаем ответы команд
#
if ($opt_m)
{
    die "Cannot open $opt_m\n" unless open(INFILE,$opt_m)
}
else
{
    *INFILE=*STDIN;
}
readmail(\%teams);
close(INFILE);
#
# Чистим хэш %answers
#
collect_answers(\%teams,\@answers);
#
# Пишем измененную таблицу в файл.
#
if ($opt_o)
{ 
    die "Cannot open $opt_o\n" unless open(OUTFILE,">$opt_o");
    select OUTFILE;
}
for ($i=1;$i<=$MAXQUEST;$i++)
{
    print "\nВОПРОС $i:\n";
    print "\nЗАСЧИТАНО:\n";
    anondump(\%teams,\@answers,$i,'+');
    print "\nНЕ ЗАСЧИТАНО:\n";
    anondump(\%teams,\@answers,$i,'-');
    print "\nНЕ ЯСНО:\n";
    anondump(\%teams,\@answers,$i,'?');
}
print "***\n";







