Catman...::MAB2(3pm)
π Catmandu::Importer::MAB2 π
okay so bestie, welcome to the Catman...::MAB2(3pm) page β yes that's the manual name, and yes it's giving "the title got cut off in a text message" energy, but we move. This is the Catmandu::Importer::MAB2 module, and it's literally just a package that imports MAB2 data. That's it. That's the whole job. And it eats. π
β¨ NAME β¨
Catmandu::Importer::MAB2 β the package that imports MAB2 data. periodt. π
πΈ SYNOPSIS πΈ
Here's the vibe, bestie β you load it up, you point it at a file, you tell it which flavour of MAB2 you're feeding it:
use Catmandu::Importer::MAB2;
my $importer = Catmandu::Importer::MAB2->new(file => "./t/mab2.dat", type=> "raw");
my $n = $importer->each(sub {
my $hashref = $_[0];
# ...
});
see how it justβ¦ goes? each hands you a $hashref and you do whatever your little heart desires with it. $n is your count. no notes. π«Ά
And if you wanna convert between MAB2 syntax variants using the catmandu command line client, this is the line, iykyk:
catmandu convert MAB2 --type raw to MAB2 --type xml < mab2.dat
π¦ MAB2 π¦
So when a MAB2 record gets parsed, what you get back is a HASH with exactly two keys, and I need you to be seated for this:
_idβ holds the001field, aka the system identifier of the record. it's the record's little government name.recordβ holds anARRAYofARRAYs, one inner array for every field. nested arrays, we love to see it. π
Here's the whole thing looking exactly like this:
{
'record' => [
[
'001',
' ',
'_',
'fol05882032 '
],
[
245,
'a',
'a',
'Cross-platform Perl /',
'c',
'Eric F. Johnson.'
],
],
'_id' => 'fol05882032'
}
look at her. _id is fol05882032, and record is out here living its best nested life. π
π METHODS π
Not me having to tell you this part but okay: this module inherits all methods of Catmandu::Importer and, by extension, Catmandu::Iterable. So everything those two bring to the table? Yeah. You get all of it. free real estate. π
π CONFIGURATION π
On top of whatever config Catmandu::Importer already gives you ("file", "fh", etc. β you know the ones), this importer takes one more parameter, and here she is:
type
Describes the MAB2 syntax variant. case ignored, so don't stress about your caps lock β supported values include:
- the default value
"xml"β for MABxml "disk"β for the human-readable MAB2 serialization (aka"Diskettenformat")"raw"β for the data-exchange MAB2 serialization (aka"Bandformat")
three flavours, one importer. pick your fighter. π§
π AUTHOR π
Johann Rolschewski <jorol@cpan.org> β the icon, the legend, the moment. π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2013 by Johann Rolschewski.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. yes bestie, it's free β go forth and remix. β¨
and that's the page, babe β this was perl v5.36.0, dated 2022-12-04, and it lives under the name Catman...::MAB2(3pm). mwah. go import something. π πβ¨π
π¦ where this page comes from
- debian bookworm: libcatmandu-mab2-perl 0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcatmandu-mab2-perl 0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatmandu-mab2-perl 0.24-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libcatmandu-mab2-perl 0.24-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms