文章来源:http://blog.sina.com.cn/s/blog_9d0445d50101czsr.html
首先需要用ppm安装DBI和DBD-mysql ,如果没有的话点击EDIT-preferences -repositories 下面的Suggested add就行了,你就可以找到更多的模块,就像ubuntu添加源一样
代码
use DBI; my $dbname = "数据库名"; my $location = "localhost"; my $database = "DBI:mysql:$dbname:$location"; my $db_user = "mysql用户名"; my $db_pass = "mysql密码"; my $dbh = DBI->connect($database,$db_user,$db_pass); my $sql = "SELECT * FROM gm_tf"; my $sth = $dbh->prepare($sql);#准备 $sth->execute() or die "无法执行SQL语句:$dbh->errstr"; #执行 while (@data = $sth->fetchrow_array()) {#fetchrow_array返回row print "Email:$data[0] Telephone:$data[1] "; } $sth->finish(); $dbh->disconnect;#断开数据库连接