This is just a posting in praise of the ZOOM Perl module.
Using ZOOM is it possible to query bunches o' things using a
consistent API. I used it to create a rudimentary Z39.50 client to
our local catalog, attached. I think ZOOM is a bit of an unsung hero.
--
Eric Lease Morgan
University Libraries of Notre Dame
#!/usr/bin/perl
# require
use MARC::Record;
use strict;
use ZOOM;
# define
use constant UNDLIBRARIES => 'alephprod.library.nd.edu:9991/ndu01pub';
# get the query
my $query = shift;
# create an connection and search
my $connection = new ZOOM::Connection( UNDLIBRARIES, 0, count => 1, preferredRecordSyntax => "usmarc" );
my $results = $connection->search_pqf( qq["$query"] );
# loop through the results
my $hits = $results->size;
my $index = 0;
my @keywords = split / /, $query;
for ( my $i = 0; $i <= $hits - 1; $i++ ) {
# get the record
my $record = $results->record( $i )->raw;
my $marc = MARC::Record->new_from_usmarc( $record );
# extract title and isbn
my $title = $marc->title;
my $isbn = $marc->field( '020' );
# bold the search terms
foreach ( @keywords ) { $title =~ s/($_)/<b>$1<\/b>/i; }
# add COinS
if ( $isbn ) {
$isbn = $isbn->subfield('a'), "\n";
my @isbn = split / /, $isbn;
$isbn = $isbn[0];
print '<span class="Z3988" title="ctx_ver=Z39.88-2004&rft_val_fmt=info:ofi/fmt:kev:mtx:book&rft.isbn=$isbn">$isbn</span><br />';
}
else { print ' isbn: ', "\n" }
# increment and check
$index++;
last if $index > 49;
}
|