Catman...c_each(3pm)
π Catmandu::Fix::Bind::marc_each π
okay bestie, welcome to the glow-up of a very specific little Perl manpage from the User Contributed Perl Documentation collection. Yes, we're in the 3pm section, yes it's giving documentation-core, and yes it's actually kind of iconic once you get it. Let's go π¦
β¨ NAME β¨
Catmandu::Fix::Bind::marc_each β a binder that loops over MARC fields. that's it, that's the whole vibe. it loops. over MARC fields. one at a time. slay π
πΈ SYNOPSIS πΈ
# Only add the 720 field to the authors when the $e subfield contains a 'promotor'
do marc_each()
if marc_match("720e","promotor")
marc_map("720ab",authors.$append)
end
end
# Delete all the 500 fields
do marc_each()
if marc_has("500")
reject()
end
end
like... look at her. two whole little routines, both wrapped in do marc_each(), both doing extremely specific things. no cap, this is the energy.
π DESCRIPTION π
so the marc_each binder literally just iterates over each individual MARC field and runs your fixes on each individual field. one field at a time, no skipping, no shortcuts, main character energy for every single field π
say your MARC record contains this:
500 $aTest
500 $aTest2$eskip
500 $aTest3
then this Fix right here π
do marc_each()
unless marc_match("500e",skip)
marc_map("500",note.$append)
end
end
will copy all the 500 fields over to the note field... except for the 500 fields that have a subfield $e equal to "skip". bye to those ones, they don't get invited π«Ά
and the result is literally:
note: [Test,Test3]
see? Test2 got left out because she had $e = skip. the binder said "not today" and honestly? respect.
β CONFIGURATION β
π var
ok so var is an optional loop variable, and when you use it, it holds a HASH stuffed with MARC field info. here's everything inside:
tag - The names of the MARC field
ind1 - The value of the first indicator
ind2 - The value of the second indicator
subfields - An array of subfield items. Each subfield item is a
hash of the subfield code and subfield value
so if you've got this MARC field:
500[1, ] $aTest$bRest
then your loop variable is gonna look like:
tag: 500
ind1: 1
ind2: ' '
subfields:
- a : Test
- b : Rest
lowkey gorgeous. highkey useful. and the loop variables let you have extra control over how the MARC fields get processed β like, you're not just along for the ride anymore, you're driving πβ¨
do marc_each(var:this)
# Set the indicator1 of all MARC 500 field to the value "3"
if all_match(this.tag,500)
set_field(tag.ind1,3)
# Store the result in the MARC file
marc_remove(500)
marc_paste(this)
end
end
note bestie: that example usesvar:this, so the loop variable is namedthis, and inside the block you're readingthis.tagand pastingthisback withmarc_paste(this). copy it exactly, don't get creative with the names unless you rename it everywhere π
π§ SEE ALSO π§
Catmandu::Fix::Bind
and that's the whole page, no filler, no fluff, every single detail preserved like the little treasure it is π
signing off with the receipts: this was perl v5.38.2, dated 2024-08-03, filed under Catman...c_each(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