version 1.6, 2000/10/22 01:25:25
|
version 1.8, 2002/11/09 01:46:24
|
Line 6 updateindex.pl - a script for creation o
|
Line 6 updateindex.pl - a script for creation o
|
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|
updateind.pl [B<-i> I<indexfile>] [B<-y>|B<-n>] |
updateind.pl [B<-i> I<indexfile>] [B<-y>|B<-n>] [B<-r>] |
|
|
|
|
=head1 DESCRIPTION |
=head1 DESCRIPTION |
Line 42 Answer 'yes' to all questions
|
Line 42 Answer 'yes' to all questions
|
|
|
Answer 'no' to all questions |
Answer 'no' to all questions |
|
|
|
=item B<-r> |
|
|
|
Remove all entries with zero QuestionNum |
|
|
=head1 BUGS |
=head1 BUGS |
|
|
The database, user and password are hardcoded. |
The database, user and password are hardcoded. |
Line 59 Boris Veytsman
|
Line 63 Boris Veytsman
|
=cut |
=cut |
|
|
use strict; |
use strict; |
use vars qw($opt_i $opt_h $opt_y $opt_n); |
use vars qw($opt_i $opt_h $opt_y $opt_n $opt_r); |
|
|
use Getopt::Std; |
use Getopt::Std; |
use DBI; |
use DBI; |
|
|
MAIN: |
MAIN: |
{ |
{ |
my $USAGE="Usage: updateindex.pl [-i indexfile] [-y|-n]\n"; |
my $USAGE="Usage: updateindex.pl [-i indexfile] [-y|-n][-r]\n"; |
getopts('hi:yn') or die $USAGE; |
my $REMOVE=0; |
|
getopts('hi:ynr') or die $USAGE; |
if ($opt_h) { |
if ($opt_h) { |
print $USAGE; |
print $USAGE; |
exit 0; |
exit 0; |
Line 79 MAIN:
|
Line 84 MAIN:
|
if ($opt_n ) { |
if ($opt_n ) { |
$decision = 'no'; |
$decision = 'no'; |
} |
} |
|
if ($opt_r) { |
|
$REMOVE=1; |
|
} |
my($source) = $opt_i; |
my($source) = $opt_i; |
my($depth, @depthId); |
my($depth, @depthId); |
my $filename; |
my $filename; |
Line 90 MAIN:
|
Line 98 MAIN:
|
} else { |
} else { |
*INFO=*STDIN; |
*INFO=*STDIN; |
} |
} |
|
|
while (<INFO>) { |
while (<INFO>) { |
chomp; |
chomp; |
s/
//; |
s/
//; |
Line 119 MAIN:
|
Line 128 MAIN:
|
} |
} |
print STDERR "Всего вопросов: ", |
print STDERR "Всего вопросов: ", |
UpdateGroup($dbh,0),"\n"; |
UpdateGroup($dbh,0),"\n"; |
|
if ($REMOVE) { |
|
print STDERR "Removing empty tours."; |
|
$dbh->do("DELETE FROM Tournaments WHERE QuestionsNum=0"); |
|
} |
|
$dbh->do("INSERT INTO Tournaments |
|
(Id, Title, ParentId, Type) |
|
VALUES |
|
(9999, 'Несортированные турниры', 0,'Г')"); |
|
|
$dbh->disconnect; |
$dbh->disconnect; |
} |
} |
|
|