--- db/prgsrc/updatedb.pl 2002/11/11 09:06:23 1.26 +++ db/prgsrc/updatedb.pl 2003/01/09 01:43:21 1.31 @@ -28,7 +28,7 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: updatedb.pl,v 1.26 2002/11/11 09:06:23 roma7 Exp $ +=head1 $Id: updatedb.pl,v 1.31 2003/01/09 01:43:21 boris Exp $ =cut @@ -36,9 +36,9 @@ use vars qw($opt_i); use Getopt::Std; getopts('i'); - +#open STDERR, ">errors"; my $Interactive=$opt_i || 0; - +my $DUMPDIR = $ENV{DUMPDIR} || "../dump"; my (%RevMonths) = ('Jan', '1', 'Feb', '2', 'Mar', '3', 'Apr', '4', 'May', '5', 'Jun', '6', @@ -58,7 +58,7 @@ my ($sth); use DBI; use strict; - +my $isunsorted=0; sub UpdateParents { my ($dbh, $ParentId, $all_qnum) = @_; if ($ParentId) { @@ -143,8 +143,9 @@ sub SelectGroup { } else { # Теперь, если файла нет в дереве турниров, никаких вопросов не # задаётся, а вместо этого он добавляется в группу 9999 - $ParentId = 9999; - print UNSORTED $source; + $ParentId = 9999; + print UNSORTED "$source".((12 -length($source))x' ')."\t$TourName\n"; + $isunsorted=1; $sth = $dbh->prepare("INSERT INTO Tournaments (Title, Type, ParentId, FileName) VALUES ($TourName, 'Ч', $ParentId, @@ -268,7 +269,7 @@ MAIN: my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") or die "Can't connect to DB chgk\n"; my @sources; - open UNSORTED, ">unsorted"; + open UNSORTED, ">$DUMPDIR/unsorted"; while ($source = shift) { push @sources,glob($source); } @@ -404,5 +405,7 @@ MAIN: &UpdateParents($dbh, $ParentId, $all_qnum); print STDERR "Всего вопросов: $all_qnum \n"; } + close UNSORTED; + unlink "unsorted" unless $isunsorted; $dbh->disconnect; }