logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Catmandu::Fix::marc_paste - paste a MARC structured field back into the MARC record

Description

       Paste a MARC stucture created by Catmandu::Fix::marc_struc back at the end of a MARC record.

Inline

       This Fix can be used inline in a Perl script:

           use Catmandu::Fix::marc_copy as => 'marc_copy';
           use Catmandu::Fix::marc_paste as => 'marc_paste';

           my $data = { record => ['650', ' ', 0, 'a', 'Perl'] };

           $data = marc_copy($data,'650','subject');
           $data = marc_paste($data,'subject');

Methods

marc_paste(JSON_PATH,[at:MARC_PATH,[equals:REGEX]])
       Paste a MARC struct PATH back in the MARC record. By default the MARC structure will be pasted at the end
       of the record. Optionally provide an "at" option to set the MARC field after which the structure needs to
       be pasted. Optionally provide a regex that should match the content of the "at" field.

       The "equals" parameter requires an "at" parameter. When both are provided, then the value of JSON_PATH
       will only be pasted if the string value of the MARC_PATH in "at" matches the regular expression "equals".

           # Paste mycopy at the end of the record
           marc_paste(mycopy)

           # Paste mycopy after the last 300 field
           marc_paste(mycopy, at:300)

           # Paste mycopy after the last 300 field with indicator1 = 1
           marc_paste(mycopy, at:300[1])

           # Paste mycopy after the last 300 field which has an 'a' subfield
           marc_paste(mycopy, at:300a)

           # Paste mycopy after the last 300 field which has an 'a' subfield equal to 'ABC'
           marc_paste(mycopy, at:300a, equals:'^ABC$')

           # Paste mycopy after the last 300 field with all concatinated subfields equal to 'ABC'
           marc_paste(mycopy, at:300, equals:'^ABC$')

Name

       Catmandu::Fix::marc_paste - paste a MARC structured field back into the MARC record

See Also

       •   Catmandu::Fix::marc_copy

       •   Catmandu::Fix::marc_cut

Synopsis

           # Copy and paste to the end of the record
           marc_copy(001, fixed001)
           set_fieldfixed001.$first.tag,002)
           marc_paste(fixed001)

           # Copy and paste in place (rename a field)
           do marc_each(var:this)
             if all_match(this.tag,001)
               # Change it
               set_field(this.tag,002)

               # Paste it back into the record
               marc_paste(this)
             end
           end

See Also