--- db/prgsrc/updatedb.pl 2009/05/02 21:23:07 1.44 +++ db/prgsrc/updatedb.pl 2010/04/24 18:13:03 1.48 @@ -28,17 +28,18 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: updatedb.pl,v 1.44 2009/05/02 21:23:07 roma7 Exp $ +=head1 $Id: updatedb.pl,v 1.48 2010/04/24 18:13:03 roma7 Exp $ =cut -use vars qw($opt_i); +use vars qw($opt_i, $opt_n); use Getopt::Std; my $unsortedname="../dump/unsorted"; -getopts('i'); +getopts('in'); #open STDERR, ">errors"; my $Interactive=$opt_i || 0; +my $newOnly = $opt_n ||0; my $DUMPDIR = $ENV{DUMPDIR} || "../dump"; my (%RevMonths) = @@ -90,7 +91,6 @@ sub parseDate { $to =~ s/-(.*)-/-$month-/; $to =~ s/-00*$/-01/; } - print Dumper($from, $to); return ($from, $to); } @@ -121,12 +121,12 @@ sub getField { next; } if ($key) { - $value .= $_; + $value .= $_."\n"; next; } } if ($key && $value) { - $value=~s/\s+$//; + $value=~s/\s+$//sm; return ($key, $value); } return (0, 0); @@ -173,8 +173,8 @@ sub SelectGroup { $sth = $dbh->prepare("INSERT INTO Tournaments (Title, Type, ParentId, FileName,CreatedAt) VALUES (".$dbh->quote($TourName).", 'Ч', $ParentId, - $source,NOW())"); - $sth->execute; + ?,NOW())"); + $sth->execute($source); my $TournamentId = $sth->{mysql_insertid}; return ($TournamentId,$ParentId); } @@ -221,6 +221,9 @@ sub CheckFile { } my($Id,$ParentId,$QuestionsNum)=@arr; if($QuestionsNum) { + if ($newOnly) { + return (0,0); + } print "Файл $source с данными $title уже существует. ", "Заменить?[y/N]\n"; my $answer = ;