in reply to Battling Getopt::Long
A Few changed and your code will work..
Try changing
tomy %opts=(GetOptions( 'help|?' => \$help, 'server' => \$server, 'user' => \$user, 'password' => \$password ));
also put everything afterGetOptions (\%opts, qw( help|h|? server=s user=s password=s ));
into and elsif statement something like&Help; }
Then for your database connection bit try using the following:&Help; } elsif( defined $opts{server} && defined $opts{user} && defined $opts{p +assword} ) { my $mytime=(time); ... } else { &Help; }
also you can't have $sth->finish if you havent prepared or ecexuted a $sth statement I.e.my $dbh; my $DSN = "driver={SQL Server};Server=$opts{server};database=$database +;"; if ($dbh = DBI->connect("dbi:ODBC:$DSN","$opts{user}","$opts{password} +")) { &Logger ("...Success: connected to database $opts{server}\\$databa +se\n"); } else { &Logger("ERROR - Cannot connect to DB: $dbh->errstr()\n"); }
Type Stuff - HTHmy $query = "select * from sometable"; my $sth = $dbh->prepare($query); for my $rec (@records) { $sth->execute(@$rec); } $setsth->finish();
Update:Sorry Typo... change $setsth->execute(@$rec); to $sth->execute(@$rec);
-----
Of all the things I've lost in my life, its my mind I miss the most.
Of all the things I've lost in my life, its my mind I miss the most.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Battling Getopt::Long
by Smaug (Pilgrim) on May 12, 2004 at 08:48 UTC |
In Section
Seekers of Perl Wisdom