Catman...c_copy(3pm)
πΈ NAME πΈ
okay bestie, first the admin: this page comes from the User Contributed Perl Documentation, living in the 3pm section (that's the Perl module section, iykyk π
). The page is titled Catman...c_copy(3pm) β yes, truncated, yes, iconic.
And the actual module it's about? Catmandu::Fix::marc_copy β it copies marc data in a structured way to a new field. Slay. β¨
π SYNOPSIS π
# Cut the 001 field out of the MARC record into the fixed001
marc_copy(001, fixed001)
# Cut all 650 fields out of the MARC record into the subjects array
marc_copy(650, subjects)
π¦ DESCRIPTION π¦
So here's the tea, bestie: this copies MARC data referred to by MARC_TAG in a structured way to a JSON path. π«Ά
And the way it's different from Catmandu::Fix::marc_map and Catmandu::Fix::marc_spec? marc_copy doesn't just copy data content (values) β it also grabs all the data elements like tag, indicators and subfield codes, and tucks them into a nested data structure. It's giving main character energy, fr fr. π
π METHODS π
π marc_copy(MARC_PATH, JSON_PATH, [equals: REGEX]) π
Copy this MARC fields referred by a MARC_PATH to a JSON_PATH. When an equals value has been provided, then only the MARC_PATHs with a value equal to equals will be copied 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.
# copy only the 100 fields which have a $a subfield
marc_copy(100a,tmp)
# copy only the 100 fields with have a $a subfield matching 'My'
marc_copy(100a,tmp,equals:"My")
# copy only the 100 fields with have a concatinated string value 'MyField.'
# (equals is an regex, the period "." needs to be escaped "\.")
marc_copy(100,tmp,equals:"MyField\.")
# copy only the 100 fields which have a "." at the end
marc_copy(100,tmp,equals:"\.$")
More examples, because we love options π :
# Copy all the 300 fields
marc_copy(300,tmp)
# Copy all the 300 fields with indicator 1 = 1
marc_copy(300[1],tmp)
# Copy all the 300 fields which have subfield c
marc_copy(300c,tmp)
# Copy all the 300 fields which have subfield c equal to 'ABC'
marc_copy(300c,tmp,equals:"^ABC")
The JSON_PATH tmp will contain an array with one item per field that was copied. Each item is a hash containing the following fields:
tmp.*.tagβ The names of the MARC fieldtmp.*.ind1β The value of the first indicatortmp.*.ind2β The value of the second indicatortmp.*.subfieldsβ An array of subfield items. Each subfield item is a hash of the subfield code and subfield value
E.g.
tmp:
- tag: '300'
ind1: ' '
ind2: ' '
subfields:
- a: 'blabla:'
- v: 'test123'
- c: 'ok123'
These JSON paths can be used like:
# 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
β¨ INLINE β¨
This Fix can be used inline in a Perl script, no cap:
use Catmandu::Fix::marc_copy as => 'marc_copy';
my $data = { record => ['650', ' ', 0, 'a', 'Perl'] };
$data = marc_copy($data,'650','subject');
print $data->{subject}->[0]->{tag} , "\n"; # '650'
print $data->{subject}->[0]->{ind1} , "\n"; # ' '
print $data->{subject}->[0]->{ind2} , "\n"; # 0
print $data->{subject}->[0]->{subfields}->[0]->{a} , "\n"; # 'Perl'
π SEE ALSO π
Catmandu::Fix::marc_cutCatmandu::Fix::marc_paste
π LICENSE AND COPYRIGHT π
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
and that's the whole page, bestie β stay hydrated, back up your data, and remember: perl v5.38.2, dated 2024-08-03, filed under Catman...c_copy(3pm) in the User Contributed Perl Documentation. periodt. πβ¨π
π¦ where this page comes from
- debian trixie: libcatmandu-marc-perl 1.320-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatmandu-marc-perl 1.320-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-marc-perl 1.320-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms