perl连接数据库的写法
use DBI; my ($host, $user, $pwd, $db)=qw //; my $dbh = DBI->connect("DBI:mysql:database=$db;host=$host","user","pwd"); my $sth = $dbh->prepare("select * from tablename where var=?"); my $value = $sth->fetchrow() if $sth->execute($tid); my $sth->finish(); $dbh->disconnect();