MARC/Perl
MARC Tutorial
Which will generate results like this:
| 600 | United States |
| 140 | World War, 1939-1945 |
| 78 | Great Britain |
| 63 | Afro-Americans |
| 61 | Indians of North America |
| 58 | American poetry |
| 55 | France |
| 53 | West (U.S.) |
| 53 | Science fiction |
| 53 | American literature |
| 50 | Shakespeare, William |
| 48 | Soviet Union |
| 46 | Mystery and detective stories |
| 45 | Presidents |
| 43 | China |
| 40 | Frontier and pioneer life |
| 38 | English poetry |
| 37 | Authors, American |
| 37 | English language |
| 35 | Japan |
HTML
XML
Excel
Z39.50
Chris Biemesderfer was kind enough to contribute a short example of how to use MARC::Record in tandem with Net::Z3950. Net::Z3950 is a CPAN module which provides an easy to use interface to the Z39.50 protocol so that you can write programs that retrieve records from bibliographic database around the world. Chris' program is a command line utility which you run like so:
./zm.pl 0596000278
where 0596000278 is an ISBN (for the 3rd edition of the Camel incidentally). The program will query the Library of Congress Z39.50 server for the ISBN, and dump out the retrieved MARC record on the screen. The program is designed to lookup multiple ISBNs if you separate them with a space. This is just an example showing what is possible.
| 1 | #!/usr/bin/perl -w |
|---|---|
| 2 | |
| 3 | # GET-MARC-ISBN -- Get MARC records by ISBN from a Z39.50 server |
| 4 | |
| 5 | use strict; |
| 6 | use Carp; |
| 7 | use Net::Z3950; |
| 8 | use MARC::Record; |
| 9 | |
| 10 | exit if ($#ARGV < 0); |
| 11 | |
| 12 | # We handle multiple ISBNs in the same query by assembling a |
| 13 | # (potentially very large) search string with Prefix Query Notation |
| 14 | # that ORs the ISBN-bearing attributes. |
| 15 | # |
| 16 | # For purposes of automation, we want to request batches of many MARC |
| 17 | # records. I am not a Z39.50 weenie, though, and I don't know |
| 18 | # offhand if there is a limit on how big a PQN query can be... |
| 19 | |
| 20 | my $zq = "\@attr 1=7 ". pop(); |
| 21 | while (@ARGV) { $zq = '@or @attr 1=7 '. pop() ." $zq" } |
| 22 | |
| 23 | ## HERE IS THE CODE FOR Z3950 REC RETRIEVAL |
| 24 | # Set up connection management structures, connect |
| 25 | # to the server, and submit the Z39.50 query. |
| 26 | |
| 27 | my $mgr = Net::Z3950::Manager->new( databaseName => 'voyager' ); |
| 28 | $mgr->option( elementSetName => "f" ); |
| 29 | $mgr->option( preferredRecordSyntax => Net::Z3950::RecordSyntax::USMARC ); |
| 30 | |
| 31 | my $conn = $mgr->connect('z3950.loc.gov', '7090'); |
| 32 | croak "Unable to connect to server" if !defined($conn); |
| 33 | |
| 34 | my $rs = $conn->search($zq); |
| 35 | |
| 36 | my $numrec = $rs->size(); |
| 37 | print STDERR "$numrec record(s) found\n"; |
| 38 | |
| 39 | for (my $ii = 1; $ii <= $numrec; $ii++) { |
| 40 | |
| 41 | # Extract MARC records from Z3950 |
| 42 | # result set, and load MARC::Record. |
| 43 | my $zrec = $rs->record($ii); |
| 44 | my $mrec = MARC::Record->new_from_usmarc($zrec->rawdata()); |
| 45 | print $mrec->as_formatted, "\n\n"; |
| 46 | |
| 47 | } |
