#! /usr/local/bin/perl use DBI; $dbname = "test"; $user = "postgres"; $passwd = "postgresdbpw"; $tbname = "addrbook"; $host = "localhost"; # # DBオープン # $db = DBI->connect("DBI:Pg:host=$host;dbname=$dbname", $user, $passwd) || die "DBI connect failed : $DBI::errstr"; # # SELECT実行 $st = $db->prepare("SELECT name,telno,email from $tbname"); $res = $st->execute; print < 簡易アドレス帳(PostgreSQL-Perl) HEADER while(@res = $st->fetchrow) { print < ROW } print < FOOTER # # 結果解放 # $st->finish; # # DBクローズ # $db->disconnect; 1;
簡易アドレス帳(PostgreSQL-Perl)
名前 電話番号 メールアドレス
$res[0] $res[1] $res[2]