--- db/prgsrc/updateindex.pl 2000/10/18 21:50:48 1.2 +++ db/prgsrc/updateindex.pl 2000/10/19 01:06:18 1.3 @@ -16,6 +16,16 @@ Upadets metainformation in the B d An example of the index file follows: + Авторские вопросы + Виктор Байрак + bayrak.txt Вопросы В.Байрака + Борис Бурда + burda.txt Вопросы Бориса Бурды + burda1.txt Тренировки Бориса Бурды 1 + burda10.txt Тренировки Бориса Бурды 10 + burda11.txt Тренировки Бориса Бурды 11 + burda12.txt Тренировки Бориса Бурды 12 + =head1 BUGS @@ -29,7 +39,7 @@ createindex.pl(1) Boris Veytsman -=head1 $Id: updateindex.pl,v 1.2 2000/10/18 21:50:48 boris Exp $ +=head1 $Id: updateindex.pl,v 1.3 2000/10/19 01:06:18 boris Exp $ =cut @@ -42,7 +52,7 @@ use DBI; MAIN: { my $USAGE="Usage: updateindex.pl -i indexfile\n"; - getopts('hm:') or die $USAGE; + getopts('hi:') or die $USAGE; if ($opt_h) { print $USAGE; exit 0; @@ -58,11 +68,11 @@ MAIN: chomp; s/ //; next if (/^\s*$/); - if (s/^(\w*)//) { # File found + if (s/^(\S+) *//) { # File found $filename = $1; $depth = -1; } else { # Group found - undef $filename; + $filename = ''; $depth = -2; } s/^(\t*)//; @@ -76,7 +86,7 @@ MAIN: my $ParentId = ($depth) ? $depthId[$depth - 1] : 0; my $sth; my $type; - if (defined $filename) { + if ($filename) { $type=$dbh->quote('Ч'); $filename = $dbh->quote($filename); $sth = $dbh->prepare("SELECT Id FROM Tournaments @@ -88,20 +98,21 @@ MAIN: } $sth = $dbh->prepare("INSERT INTO Tournaments (Title, ParentId, FileName, Type) - VALUES ($title, $ParentId, $filename, $type;)"); + VALUES ($title, $ParentId, $filename, $type)"); $sth->execute; } else { - $sth->execute; + $type=$dbh->quote('Г'); $sth = $dbh->prepare("SELECT Id FROM Tournaments WHERE Title=$title"); - $type=$dbh->quote('Г'); + + $sth->execute; if ($sth->fetchrow) { print "$title is already in the DB!\n"; next; } $sth = $dbh->prepare("INSERT INTO Tournaments (Title, ParentId, Type) - VALUES ($title, $ParentId, $type;)"); + VALUES ($title, $ParentId, $type)"); $sth->execute; my $Id = $sth->{'mysql_insertid'}; $depthId[$depth] = $Id;