DB

mysql接続
use DBI qw(:sql_types);
$dbh = DBI->connect('DBI:mysql:データベース名:ホスト名:ポート','ユーザーID','パス');
$dbh->do("set names utf8"); // クライアントの文字セット
$sth = $dbh->prepare("select * from t1 where id=? and name=?");
$sth->bind_param(1, 2, SQL_INTEGER);
$sth->bind_param(2, $name, SQL_VARCHAR);
$sth->execute;
■添え字配列
while ( my $arr_ref = $sth->fetchrow_arrayref ){
my ($hoge, $fuga, $text, $ymd) = @$arr_ref;
print "$hoge $fuga $text $ymd\n\n";
}
連想配列
while ( my $hash_ref = $sth->fetchrow_hashref ){
print "name=[$hash_ref->{'name'}] text=[$hash_ref->{'text'}]\n";
}