Catman...::MAB2(3pm)

πŸ“¦
version 0.24 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– 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 the 001 field, aka the system identifier of the record. it's the record's little government name.
  • record β€” holds an ARRAY of ARRAYs, 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. 🫢


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