Author image Andreas J. König


MAB2::Record::Base - Access an MAB2 record


 use MAB2::Record::Base;

 # Constructor
 my $mab2raw = "00296nM2.01200024      k001 1000016-1\c^002a19890418".
    "\c^004 20010812\c^028b1000016-1\c^029 HK00158537\c^030 aa1dc".
    "|m\c^036aIT\c^066 |\c^070 9002\c^070aHBZ\c^800 Accademia Na".
    "zionale di San Luca <Roma>\c^810 Accademia di San Luca <Roma, A".
    "ccademia Nazionale di San Luca>\c^850aReale Accademia di San Lu".
    "ca <Roma>\c^852a45335-3\c^\c]";
 my $mab2 = MAB2::Record::Base->new($mab2raw);
 # $mab2 now blessed into MAB2::Record::gkd because it is a gkd record

 # various representations:
 print $mab2->id;             # just the ID
 print $mab2->readable;       # quite readable
 print $mab2->as_string;      # the raw string we put into it
 print $mab2->dump;           # only useful for debugging the module itself


MAB2::Record::Base is the common base class for all classes implementing MAB2 record types:


The constructor new takes a raw MAB2 record as argument and returns an object which is blessed into one of the five above listed classes. Some level of proficiency in dealing with MAB2 records is needed for the user of this module for further processing of the objects. It is recommended to use Data::Dumper to get acquainted with the raw format of the created objects.

For illustration purpose, here is the Data::Dumper output of the full object into which the sample record from the SYNOPSIS section is transformed:

  $VAR1 = bless( [
                       'nicht_benutzt' => [
                                            '      '
                       'datenanfangsadresse' => [
                       'satztyp' => [
                                      'Koerperschaftsnamensatz (MAB-GKD)'
                       'versionsangabe' => [
                       'satzstatus' => [
                                         'neuer Datensatz'
                       'indikatorlaenge' => [
                       'satzlaenge' => [
                       'teilfeldkennungslaenge' => [
                         ' ',
                         'identifikationsnummer des datensatzes'
                         'datum der ersterfassung / fremddatenuebernahme'
                         ' ',
                         'erstellungsdatum des austauschsatzes'
                         ' ',
                         'Accademia di San Luca <Roma, Accademia Nazionale di San 
                         '1. verweisungsform zum namen der koerperschaft'
                         'Reale Accademia di San Luca <Roma>',
                         '1. frueherer, zeitweiser oder spaeterer name der koerper
                         'identifikationsnummer des 1. frueheren, zeitweisen oder 
  spaeteren namens'
                 ], 'MAB2::Record::gkd' );

Please note that the object contains both the original string in its own byte oriented encoding and all fields in Unicode. The conversion is done by the Encode::MAB2 module.

The normal way of accessing MAB2 records is through the use of either the Tie::MAB2::Recno or Tie::MAB2::Id class. The Tie::MAB2::Recno class binds an MAB2 file to an array and each record in the original MAB2 file to an array element starting with element 0. The Tie::MAB2::Id class binds to a hash with the MAB2 identifier as the key.


The tied objects have their stringifier overloaded to the as_string() method so that

    print $tie[1234];

always prints the record as the unaltered original input record.


Encode::MAB2, Tie::MAB2::Recno, Tie::MAB2::Id