#!/usr/bin/perl -wT
use strict;
use diagnostics;
use DBI;
my $dbh = DBI->connect('DBI:Pg:dbname=local_medline', 'dewey', '',
{AutoCommit=>1, RaiseError=>1})
or die "Unable to make database connection: $DBI::errstr\n";
my $sql = <<'EOSQL';
SELECT citation, title, authors, pubmed_id
FROM refs
WHERE authors LIKE ?
EOSQL
my $sth = $dbh->prepare($sql);
print "Search for which name? ";
while (<>) {
chomp;
my $search_key = '%' . $_ . '%';
$sth->execute($search_key);
while (my ($so, $ti, $au, $pmid) = $sth->fetchrow_array) {
print "--------------------\n";
print "TI:\t$ti\n";
print "SO:\t$so\n";
my $comma_authors = join(', ', split(/\n/, $au));
print "AU:\t$comma_authors\n";
print "PMID:\t $pmid\n";
}
print "\nSearch for which name? ";
}
syntax highlighted by Code2HTML, v. 0.8.11