具体情况就是插入多条记录
#!/usr/bin/perl
use DBI;
open AA,"c1";
my $dbname="sverlog";
my $location="localhost";
my $port="3306";
my $database="DBI:MysqL:$dbname:$location:$port";
$dbh = DBI->connect($database,"mcshell","mcshell");
while(<AA>){
chomp;
if (/[^www]\s+(\S+)\s+(\S+);/){
my $sql="insert into webconfig (domain,webdir) values('$1','$2')";
my $sth=$dbh->prepare($sql);
$sth->execute() or die "无法执行sql语句:$dbh->errstr";
}
}
$dbh->disconnect();
close AA;
use DBI;
open AA,"c1";
my $dbname="sverlog";
my $location="localhost";
my $port="3306";
my $database="DBI:MysqL:$dbname:$location:$port";
$dbh = DBI->connect($database,"mcshell","mcshell");
while(<AA>){
chomp;
if (/[^www]\s+(\S+)\s+(\S+);/){
my $sql="insert into webconfig (domain,webdir) values('$1','$2')";
my $sth=$dbh->prepare($sql);
$sth->execute() or die "无法执行sql语句:$dbh->errstr";
}
}
$dbh->disconnect();
close AA;
while(my @row=$sth->fetchrow_array()){ print ("@row\n"); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。