Last active
August 29, 2015 14:06
-
-
Save kazmura11/d678a22888f4d1498c05 to your computer and use it in GitHub Desktop.
DBD::CSVのテスト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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