Scroll to navigation

Catmandu::Fix::marc_map(3pm) User Contributed Perl Documentation Catmandu::Fix::marc_map(3pm)


Catmandu::Fix::marc_map - copy marc values of one field to a new field


    # Append all 245 subfields to my.title field the values are joined into one string
    # Append al 245 subfields to the my.title keeping all subfields as an array
    marc_map('245','my.title', split:1)
    # Copy the 245-$a$b$c subfields into the my.title hash in the order provided in the record
    # Copy the 245-$c$b$a subfields into the my.title hash in the order c,b,a
    marc_map('245cba','my.title', pluck:1)
    # Add the 100 subfields into the my.authors array
    # Add the 710 subfields into the my.authors array
    # Add the 600-$x subfields into the my.subjects array while packing each into a genre.text hash
    # Copy the 008 characters 35-37 into the my.language hash
    # Copy all the 600 fields into a my.stringy hash joining them by '; '
    marc_map('600','my.stringy', join:'; ')
    # When 024 field exists create the my.has024 hash with value 'found'
    marc_map('024','my.has024', value:found)
    # When 260c field exists create the my.has260c hash with value 'found'
    marc_map('260c','my.has260c', value:found)
    # Copy all 100 subfields except the digits to the 'author' field
    # Map all the 500 - 599 fields to my.notes
    # Map the 100-a field where indicator-1 is 3
    # Map the 245-a field where indicator-2 is 0
    # Map the 245-a field where indicator-1 is 1 and indicator-2 is 0


Copy data from a MARC field to JSON path.

This module implements a small subset of the MARCspec <> specification to map MARC fields. For a more extensive MARC path implementation please take a look at Casten Klee's MARCSpec module: Catmandu::Fix::marc_spec



Copy the value(s) of the data found at a MARC_PATH to a JSON_PATH.

The MARC_PATH can point to a MARC field. For instance:


The MARC_PATH can point to one or more MARC subfields. For instamce:


You can also use dollar signs to indicate subfields


Wildcards are allowed in the field names:

    # Map all the 200-fields to a title

To filter out specific fields indicators can be used:

    # Only map the MARC fields with indicator-1 is '1' to title

Also a substring of a field value can be mapped:

    # Map 008 position 35 to 37 to the language field

By default all matched fields in a MARC_PATH will be joined into one string. This behavior can be changed using one more more options (see below).

Visit our Wiki <> for a complete overview of all allowed mappings.


split: 0|1

When split is set to 1 then all mapped values will be joined into an array instead of a string.

    # The subject field will contain an array of strings (one string
    # for each 500 field found)
    marc_map('500',subject, split: 1)
    # The subject field will contain a string
    marc_map('500', subject)

join: Str

By default all the values are joined into a string without a field separator. Use the join function to set the separator.

    # All subfields of the 245 field will be separated with a space " "
    marc_map('245',title, join: " ")

pluck: 0|1

Be default, all subfields are added to the mapping in the order they are found in the record. Using the pluck option, one can select the required order of subfields to map.

    # First write the subfield-c to the title, then the subfield_a
    marc_map('245ca',title, pluck:1)

value: Str

Don't write the value of the MARC (sub)field to the JSON_PATH but the specified string value.

    # has_024_a will contain the value 'Y' if the MARC field 024 subfield-a
    # exists

nested_arrays: 0|1

When the split option is specified the output of the mapping will always be an array of strings (one string for each subfield found). Using the nested_array option the output will be an array of array of strings (one array item for each matched field, one array of strings for each matched subfield).


This Fix can be used inline in a Perl script:

    use Catmandu::Fix::marc_map as => 'marc_map';
    my $data = { record => [...] };
    $data = marc_map($data,'245a','title');
    print $data->{title} , "\n";


Catmandu::Fix Catmandu::Fix::marc_spec

2019-02-25 perl v5.28.1