--- db/prgsrc/updatem.pl 2000/10/17 01:34:16 1.1 +++ db/prgsrc/updatem.pl 2000/10/17 01:47:34 1.2 @@ -22,29 +22,34 @@ The database, user and password are hard Dmitry Rubinstein -=head1 $Id: updatem.pl,v 1.1 2000/10/17 01:34:16 boris Exp $ +=head1 $Id: updatem.pl,v 1.2 2000/10/17 01:47:34 boris Exp $ =cut + use strict; +use vars qw($opt_m); + +use Getopt::Std; use DBI; MAIN: { - - my($source) = 'meta'; + getopts('m:') or die "Wrong options"; + my($source) = $opt_m || 'meta'; my($depth, @depthId); my($dbh) = DBI->connect("DBI:mysql:chgk", "piataev", "") or die "Can't connect to DB chgk\n"; open INFD, $source or die "Can't open input file: $!\n"; while () { + my $MetaId; s/^\[(\d*)\]\t//; $MetaId = $1; s/^(\t*)//; chomp; $depth = length($1); - $title = $dbh->quote($_); - $ParentId = ($depth) ? $depthId[$depth - 1] : 0; + my $title = $dbh->quote($_); + my $ParentId = ($depth) ? $depthId[$depth - 1] : 0; my ($sth) = $dbh->prepare("SELECT Id FROM Tournaments WHERE MetaId=$MetaId"); $sth->execute; @@ -56,7 +61,7 @@ MAIN: (Title, ParentId, MetaId, Type) VALUES ($title, $ParentId, $MetaId, 'ç')"); $sth->execute; - $Id = $sth->{insertid}; + my $Id = $sth->{'insertid'}; $depthId[$depth] = $Id; } $dbh->disconnect;