Is there an easy perl way to retrieve a MARC record for a given ISBN?
Yes, using Z39.50! :-)
With Net::Z3950 you can do something like this (untested, error handling omitted):
use Net::Z3950;
my %options = (
'databaseName' => $db_name,
'querytype' => 'prefix',
'preferredRecordSyntax' => 19, # USMARC
... other options ...
);
my %searches = (
'isbn' => '@attr 1=7 @attr 4=1 "%s"',
'issn' => '@attr 1=8 @attr 4=1 "%s"',
... other types of search if desired ...
);
my $conn = Net::Z3950::Connection->new($host, $port, %options);
my $result_set = $conn->search(sprintf $searches{isbn}, $isbn);
foreach my $i (1..$result_set->size) {
my $record = $result_set->record($i);
my $marc = MARC::Record->new_from_usmarc($record->rawdata);
... do something with the record ...
}
$conn->close;You can use syntaxes other than prefix, but that's the one I know best.
FWIW, the specs on bib-1 searches in Z39.50 aren't too horribly complicated:
ftp://ftp.loc.gov/pub/z3950/defs/bib1.txt
Some good Z39.50 resources are available:
http://www.ilrt.bris.ac.uk/discovery/z3950/resources/ http://www.niso.org/standards/resources/Z3950_Resources.html
The Library of Congress keeps a list of servers that have been made available for testing purposes, including their own:
http://lcweb.loc.gov/z3950/agency/resources/testport.html
Make sure you read the info here before using them:
http://lcweb.loc.gov/z3950/agency/proced.html#hosts
FWIW, I'm working on a Perl module that makes bib-1 searching via Z39.50 a bit simpler:
use Zoose;
$z = Zoose->new(
'host' => $host,
'port' => $port,
...
);
$rs = $z->search('isbn' => $isbn);
foreach my $i (1..$rs->count) {
$book = $rs->match($i);
print $book->title_proper, "\n";
... other MARC::Record operations here ...
}But it will be a little while till it's ready for release. Bug me if you want me to hurry. :-)
HTH,
Paul.
-- Paul Hoffman :: Taubman Medical Library :: Univ. of Michigan [EMAIL PROTECTED] :: [EMAIL PROTECTED] :: http://www.nkuitse.com/
