Skip to content

Instantly share code, notes, and snippets.

@kazmura11
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save kazmura11/d678a22888f4d1498c05 to your computer and use it in GitHub Desktop.

Select an option

Save kazmura11/d678a22888f4d1498c05 to your computer and use it in GitHub Desktop.
DBD::CSVのテスト
#!/usr/bin/perl
binmode(STDOUT, ":utf8"); # utf-8でCSVファイルを作っているための対策
use DBI;
$dbh = DBI->connect("dbi:CSV:", undef, undef, {
f_ext => ".csv/r",
RaiseError => 1,
}) or die "Cannot connect: $DBI::errstr";
my $sth = $dbh->prepare("select * from english_name");
$sth->execute;
$sth->bind_columns(\my ($eng_name, $eng_nick_name, $sex, $jpn_name));
while ($sth->fetch) {
print "$eng_name\t$eng_nick_name\t$sex\t$jpn_name\n";
}
$dbh->disconnect;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment