version 1.13, 2000/10/22 04:44:53
|
version 1.15, 2000/10/22 06:03:35
|
Line 78 sub getField {
|
Line 78 sub getField {
|
} |
} |
next if (/^\s*$/); |
next if (/^\s*$/); |
|
|
if (s/^(.*?)[:\.]\s*// && !$key) { |
if (/^(.*)[:\.]\s*/ && !$key) { |
$key = $1; |
$key = $1; |
$value=$_; |
|
next; |
next; |
} |
} |
if ($key) { |
if ($key) { |
Line 227 MAIN:
|
Line 226 MAIN:
|
# Inherited fields for a Question |
# Inherited fields for a Question |
# |
# |
my %QuestionFields = ('Тип'=> 'Type', 'Вид'=> 'Type', |
my %QuestionFields = ('Тип'=> 'Type', 'Вид'=> 'Type', |
'Автор' => 'Authors', |
'Автор' => 'Authors', 'Рейтинг'=>'Rating', |
'Источник' => 'Source'); |
'Источник' => 'Sources'); |
|
|
|
|
my($source); |
my($source); |
Line 239 MAIN:
|
Line 238 MAIN:
|
while ($source = shift) { |
while ($source = shift) { |
my($PlayedAt) = ''; |
my($PlayedAt) = ''; |
my($QuestionId, $TourId, $TournamentId, $ParentId) = (0, 0, 0, 0); |
my($QuestionId, $TourId, $TournamentId, $ParentId) = (0, 0, 0, 0); |
my($tournum, $qnum, $all_qnum, $qtype) = (0, 0, 0, 'Ч'); |
my($tournum, $qnum, $all_qnum) = (0, 0, 0); |
my (@d) = (localtime((stat($source))[9]))[5,4,3]; |
my (@d) = (localtime((stat($source))[9]))[5,4,3]; |
$d[1]++; |
$d[1]++; |
$d[0]+=1900; |
$d[0]+=1900; |
Line 253 MAIN:
|
Line 252 MAIN:
|
print STDERR "Файл: $source, дата: $CreatedAt "; |
print STDERR "Файл: $source, дата: $CreatedAt "; |
my %TourDefaults=('CreatedAt'=>$CreatedAt); |
my %TourDefaults=('CreatedAt'=>$CreatedAt); |
my %QuestionDefaults=(); |
my %QuestionDefaults=(); |
my %QuestionGlobalDefaults=(); |
my %QuestionGlobalDefaults=('Type'=>$dbh->quote('Ч')); |
while (($key, $value) = getField(\*INFD, $dbh)) { |
while (($key, $value) = getField(\*INFD, $dbh)) { |
last if (!$key); |
last if (!$key); |
|
|
Line 294 MAIN:
|
Line 293 MAIN:
|
%QuestionDefaults=%QuestionGlobalDefaults; |
%QuestionDefaults=%QuestionGlobalDefaults; |
} |
} |
my $query = "INSERT INTO Questions |
my $query = "INSERT INTO Questions |
(ParentId, Number, Type) |
(ParentId, Number) |
VALUES ($TourId, $qnum+1, \'$qtype\')"; |
VALUES ($TourId, $qnum+1)"; |
$sth = $dbh->prepare($query); |
$sth = $dbh->prepare($query); |
$sth->execute or print $query;; |
$sth->execute or print $query;; |
$QuestionId = $sth->{mysql_insertid}; |
$QuestionId = $sth->{mysql_insertid}; |
Line 318 MAIN:
|
Line 317 MAIN:
|
next; |
next; |
} |
} |
|
|
my @Fields = grep /$key/, keys %QuestionFields; |
my @Fields = grep { $key =~ /$_/ } keys %QuestionFields; |
|
|
if (scalar @Fields) { |
if (scalar @Fields) { |
my $word = shift @Fields; |
my $word = shift @Fields; |
Line 333 MAIN:
|
Line 332 MAIN:
|
next; |
next; |
} |
} |
|
|
@Fields = grep /$key/, keys %TourFields; |
@Fields = grep { $key =~ /$_/ } keys %TourFields; |
|
|
if (scalar @Fields) { |
if (scalar @Fields) { |
my $word = shift @Fields; |
my $word = shift @Fields; |