#!/usr/local/bin/perl
#$Id: processmail.pl,v 2.1 2005/01/24 03:14:49 boris Exp $
#
#
# Исходные файлы и параметры
#

    use Getopt::Std; 

$usage = 'processmail.pl $Revision: 2.1 $, $Date: 2005/01/24 03:14:49 $'. "\n".
"Usage: processmail.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++)
{
    foreach $symbol ('+','-','?')
    {
	dumphash(\%teams,\@answers,$i,$symbol);
    }
}
print "***\n";


