Catman...Record(3pm)
πΈ Catman...Record(3pm) β Catmandu::Importer::MARC::Record πΈ
okay bestie, so you found a perl manpage and you're like "what is this" β don't worry, I got you. This one lives in the User Contributed Perl Documentation corner of your system, and it's literally about a package that imports an array of MARC::Record into Catmandu. MARC records in, Catmandu items out. That's the whole vibe. π
β¨ NAME β¨
Catmandu::Importer::MARC::Record β the package that imports an array of MARC::Record. yep, that's the name, that's the job, no notes. π
π¦ SYNOPSIS π¦
here's how you actually use it, in all its perl glory β copy it exactly, don't be cute with it:
# From perl
use Catmandu;
use MARC::Record;
my $record = MARC::Record->new();
my $field = MARC::Field->new('245','','','a' => 'My title.');
$record->append_fields($field);
# import records from file
my $importer = Catmandu->importer('MARC',file => '/foo/data.mrc' , records => [$record]);
my $fixer = Catmandu->fixer("marc_map('245a','title')");
$importer->each(sub {
my $item = shift;
...
});
# or using the fixer
$fixer->fix($importer)->each(sub {
my $item = shift;
printf "title: %s\n" , $item->{title};
});
so like β you build a MARC::Record, you shove a MARC::Field in there (245 with subfield a, iconic), you hand the whole array to the importer, and then either iterate raw or run it through the fixer first and get a cute little title key out the other side. it's giving pipeline. π
π METHODS π
π new(records => [ <Marc::Record> , ... ] , id => $field)
this is the constructor, bestie. it parses an array of MARC::Record into a Catmandu::Iterable β one record at a time, all chill.
and optionally you can hand it an id attribute, which tells it where to pull the system identifier from for the _id field. like, the source of the id. for example '001'. that's it, that's the option. π«Ά
π INHERTED METHODS π
(yes, it says "INHERTED", we're keeping it, it's part of the charm π)
counteach(&callback)...
and here's the tea: every Catmandu::Importer is a Catmandu::Iterable, so all its methods are inherited. all of them. the whole menu. so don't come for me asking where count came from β it's inherited, periodt. π
π₯ SEE ALSO π₯
MARC::Record
go read that one too if you wanna understand what you're actually feeding in here. iykyk. β¨
made with perl v5.38.2, dated 2024-08-03 β shoutout to the perl gang, ily, mwah π
π¦ 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