Purpose:
The purpose of this package is to facilitate the conversion of data from the marc exchange format to any other format, be it SQL, comma deliminated files or plain text files. This package is essentially a collection of functions that facilitate the handling of data in the Marc Exchange Record format. For the purposes of being concise the Marc Exchange Record format will hereafter be called MER.
Sample usage:
This sample program would generate a name list from Gelmir. Gelmir is a Libertas database that is at the National and University Library of Iceland to contains the bibliographic catalogue for manuscripts.
#!/usr/bin/perl
use marc;
my (@record) = ();
# For all records on stdin
while ( (@record = &marc::read_record()) != () )
{
my (@s700) = ();
my ($s972) = "";
@s700 = &marc::read_all_tags("700", @record);
$s972 = &marc::read_single_tag("972", @record);
foreach ( @s700 ) {
my ($first) = &marc::read_marc_tag($_, "a");
my ($last) = &marc::read_marc_tag($_, "b");
my ($timabil) = &marc::read_marc_tag($_, "c");
my ($type) = &marc::read_marc_tag($_, "y");
my ($key) = &marc::read_marc_tag($s972, "a");
print "'$key':'$first':'$last':'$timabil':'$type'\n";
}
}
Function Prototypes:
# Functions that deal with records of the format Marc Exchange Record
sub ReadMarcTags($) {} # Read all tags from a single exchange marc record
sub ReadMarcSubTags($) {} # Read all tags and subtags from a single exchange marc record
sub GetRecordExchange($) {} # Use get a @record file from a single march exhange line
# Functions that deal with expanded Marc Record
sub read_record {} # Read a single record from stdin, starting with MARC_BEGIN ending with MARC_END
# Functions that deal with processed Marc Exchange Records
sub read_all_tags(@) {} # Use this to go through a single record and locate all specific tags
sub read_single_tag(@) {} # Use this to go through a single record and locate a single tag
# Functions that deal with a single tag within a proccessed Marc Record
sub read_marc_tag($$) {} # Read tag from strings like 700 $aflepflep $basdsda $chehehe
# Translation functions for Marc Exchange Records
sub translate_marc($) {} # Translate from Exchange Marc to ISO-8859-1
sub translate($) {} # Translate from a string from Exchange marc to ISO-8859-1
# Misc. Functions
sub GetMarcHeader($) {} # Get the marc record header, used for deconstructing and reconstructing marc record
sub Merge(@) {} # Merge two different marc records together
sub CreateMarc(@) {} # Creates a Marc record from a list of tags
Function documentation:
ReadMarcTags($);
Takes in a single MER and returns a list of @tag, @len, @pos which can the be used to resolv any tag in the MER that is wished for.
ReadMarcSubTags($);
Takes in a single MER and returns a list of @tag, @len, @pos which can then be used to resolve any that in MER. This list also inclueded each and every subtag in the MER.
GetRecordExchange($);
Returns single processed record form a single line MER. This record can then be used to further process the data.
read_record; Reads a single record from STDIN starting with MARC_BEGIN and ending with MARC_END.
read_all_tags(@);
Takes in a single record and returns a list of tags matching the tag being searched for. This is typically used as @s700 = &marc::read_all_tags("700", @record);. In this case the @s700 would contain all tags in the marc exhcnage record that start with 700.
read_single_tag(@);
Takes in a single record and returns the first tag matchin the tag being searched for. This is like running read_all_tags but only using the first tag.
read_marc_tag($$);
After the data has been converted from the exchange marc format it is usually stored in lines like "300 00 $a 27 bl. $c 16.9 x 10.8 sm". To be able to extract the subtags from data like this use calls like marc::read_marc_tag($line, "c");. This would return "16.9 x 10.8 sm" for the example above.
translate($);
Translates a string from the MER format to iso-8859-1 format. This is needed because the MER format defines its own encoding.