--- db/prgsrc/updatedb.pl 2000/10/22 05:10:12 1.14 +++ db/prgsrc/updatedb.pl 2000/11/11 03:58:59 1.18 @@ -22,7 +22,7 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: updatedb.pl,v 1.14 2000/10/22 05:10:12 boris Exp $ +=head1 $Id: updatedb.pl,v 1.18 2000/11/11 03:58:59 boris Exp $ =cut @@ -78,9 +78,9 @@ sub getField { } next if (/^\s*$/); - if (s/^(.*?)[:\.]\s*// && !$key) { + if (!$key && /^(.*?)[:\.]\s*(.*)$/s) { $key = $1; - $value=$_; + $value=$2; next; } if ($key) { @@ -199,10 +199,10 @@ sub GetTours { } sub CreateTour { - my ($dbh,$title,$ParentId,$rh_defaults)=@_; + my ($dbh,$title,$ParentId,$TourNum,$rh_defaults)=@_; my $sth = $dbh->prepare("INSERT INTO Tournaments - (Title, Type, ParentId) - VALUES ($title, 'Т', $ParentId)"); + (Title, Type, ParentId, Number) + VALUES ($title, 'Т', $ParentId, $TourNum)"); $sth->execute; my $TourId = $sth->{mysql_insertid}; while (my ($key,$value)=each %$rh_defaults) { @@ -227,7 +227,7 @@ MAIN: # Inherited fields for a Question # my %QuestionFields = ('Тип'=> 'Type', 'Вид'=> 'Type', - 'Автор' => 'Authors', + 'Автор' => 'Authors', 'Рейтинг'=>'Rating', 'Источник' => 'Sources'); @@ -237,6 +237,7 @@ MAIN: or die "Can't connect to DB chgk\n"; while ($source = shift) { + my $TourNum=0; my($PlayedAt) = ''; my($QuestionId, $TourId, $TournamentId, $ParentId) = (0, 0, 0, 0); my($tournum, $qnum, $all_qnum) = (0, 0, 0); @@ -281,7 +282,9 @@ MAIN: WHERE Id=$TourId"); } $qnum = 0; - $TourId=CreateTour($dbh,$value,$TournamentId,\%TourDefaults); + $TourNum++; + $TourId=CreateTour($dbh,$value,$TournamentId,$TourNum, + \%TourDefaults); %QuestionDefaults=%QuestionGlobalDefaults; $QuestionId=0; next; @@ -318,7 +321,7 @@ MAIN: next; } - my @Fields = grep /$key/, keys %QuestionFields; + my @Fields = grep { $key =~ /$_/ } keys %QuestionFields; if (scalar @Fields) { my $word = shift @Fields; @@ -333,7 +336,7 @@ MAIN: next; } - @Fields = grep /$key/, keys %TourFields; + @Fields = grep { $key =~ /$_/ } keys %TourFields; if (scalar @Fields) { my $word = shift @Fields;