DESCRIPTION

METHODS

marc_cut(MARC_PATH, JSON_PATH, [equals: REGEX])

Cut this MARC fields referred by a MARC_PATH to a JSON_PATH. hen an equals value has been provided, then only the MARC_PATHs with a value equal to equals will be cut to JSON_PATH. When the MARC_PATH points to a subfield, then the subfield value need to match equals. When the MARC_PATH points multiple subfields, then a concatinated string value needs to match equals:

Data:
100 $aMy$bField.
# cut only the 100 fields which have a $a subfield
marc_cut(100a,tmp)
# cut only the 100 fields with have a $a subfield matching 'My'
marc_cut(100a,tmp,equals:"My")
# cut only the 100 fields with have a concatinated string value 'MyField.'
# (equals is an regex, the period "." needs to be escaped "\.")
marc_cut(100,tmp,equals:"MyField\.")
# cut only the 100 fields which have a "." at the end
marc_cut(100,tmp,equals:"\.$")

More examples:

# Cut all the 300 fields
marc_cut(300,tmp)
# Cut all the 300 fields with indicator 1 = 1
marc_cut(300[1],tmp)
# Cut all the 300 fields which have subfield c
marc_cut(300c,tmp)
# Cut all the 300 fields which have subfield c equal to 'ABC'
marc_cut(300c,tmp,equals:"^ABC")

The JSON_PATH tmp will contain an array with one item per field that was cut. Each item is a hash containing the following fields:

tmp.*.tag - The names of the MARC field
tmp.*.ind1 - The value of the first indicator
tmp.*.ind2 - The value of the second indicator
tmp.*.subfields - An array of subfield items. Each subfield item is a
hash of the subfield code and subfield value

# Set the first indicator of all 300 fields
do marc_each(var:this)
if all_match(this.tag,300)
# Set the first indicator to 1
set_field(this.ind1,1)
marc_paste(this)
end
end
# Capitalize all the v subfields of 300
do marc_each(var:this)
if all_match(this.tag,300)
do list(path:this.subfields, var:loop)
if (exists(loop.v))
upcase(loop.v)
end
end
marc_paste(this)
end
end

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.