#!/home/eric/bin/perl # zoom.pl - a simple z39.50 client # Eric Lease Morgan # 2007-06-05 - based on previous work with ZOOM Perl # require use MARC::Record; use strict; use ZOOM; # define the server to search use constant SERVER => 'localhost:9999/catalog'; # get the query my $query = shift; # sanity check if ( ! $query ) { print "Usage: $0 query\n"; exit; } # create an connection and search my $connection = new ZOOM::Connection( SERVER, 0, count => 1, preferredRecordSyntax => "usmarc" ); my $results = $connection->search_pqf( qq["$query"] ); my $hits = $results->size; # loop through (some of) the hits for ( my $i = 0; $i < $hits; $i++ ) { # get the record my $record = $results->record( $i )->raw; my $marc = MARC::Record->new_from_usmarc( $record ); # extract some data my $author = $marc->author; my $title = $marc->title_proper; my $date = $marc->publication_date; # display print " record: " , $i+1 , " of $hits\n"; print " author: $author\n"; print " title: $title\n"; print " date: $date\n"; print "\n"; }