NAME
Catmandu::Fix::Bind::marc_each - a binder that loops over MARC fields
SYNOPSIS
# Only add the 720 field to the authors when the $e subfield contains a 'promotor'do marc_each()if marc_match("720e","promotor")marc_map("720ab",authors.$append)endend# Delete all the 500 fieldsdo marc_each()if marc_has("500")reject()endend
DESCRIPTION
The marc_each binder will iterate over each individual MARC field and execute the fixes on each individual field.
When a MARC record contains:
500 $aTest500 $aTest2$eskip500 $aTest3
then the Fix bellow will copy all 500 fields to note field, except for 500 fields with a subfield $e equal to "skip".
do marc_each()unless marc_match("500e",skip)marc_map("500",note.$append)endend
The result will be:
note: [Test,Test3]
CONFIGURATION
var
Optional loop variable which contains a HASH containing MARC field information with the following fields:
tag - The names of the MARC fieldind1 - The value of the first indicatorind2 - The value of the second indicatorsubfields - An array of subfield items. Each subfield item is ahash of the subfield code and subfield value
Given the MARC field:
500[1, ] $aTest$bRest
the loop variable will contain:
tag: 500ind1: 1ind2: ' 'subfields:- a : Test- b : Rest
The loop variables can be used to have extra control over the processing of the MARC fields.
do marc_each(var:this)# Set the indicator1 of all MARC 500 field to the value "3"if all_match(this.tag,500)set_field(tag.ind1,3)# Store the result in the MARC filemarc_remove(500)marc_paste(this)endend
SEE ALSO
Catmandu::Fix::Bind