[librecat-dev] Adding MARC subfields using Catmandu

Basil Marti basil.marti at unibas.ch
Fri May 19 16:11:15 CEST 2017

Dear all

Is there an elegant way (either using the Catmandu fix-language or using Catmandu inside a Perl script) to add subfields to an existing MARC field, without replacing existing subfields?

E.g. if some condition is true, add subfield $h with content "Microfilm" to field 245.

I could use marc_set('245h','Microfilm'), but if I understand its behavior correctly, it will replace any existing subfield $h.

The only way I found is reading out all existing 245 subfields, deleting the field and and then creating a new 245 field with both the original subfields and the new subfield:

if "some condition"
     marc_remove ('245')
     marc_add('245', 'a', '$.title', 'b', '$.subtitle', 'c', '$.author', 'h', '$.medium', 'h', 'Microfilm')

Especially if a field has a lot of different subfields and/or repeatable subfields this is rather complicated. Is there any easier way?

Best regards


Basil Marti | Systembibliothekar
Universität Basel | Universitätsbibliothek | IT-Abteilung
Schönbeinstrasse 18-20 | 4056 Basel | Schweiz
Tel +41 61 207 11 88 | Fax +41 61 207 31 03
E-Mail basil.marti at unibas.ch | http://www.ub.unibas.ch

More information about the librecat-dev mailing list