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:
MAB2::Record::Base
MAB2::Record::gkd MAB2::Record::lokal MAB2::Record::pnd MAB2::Record::swd MAB2::Record::titel
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.
new
Data::Dumper
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( [ '...', undef, [ { 'nicht_benutzt' => [ ' ' ], 'datenanfangsadresse' => [ '00024' ], 'satztyp' => [ 'k', 'Koerperschaftsnamensatz (MAB-GKD)' ], 'versionsangabe' => [ 'M2.0' ], 'satzstatus' => [ 'n', 'neuer Datensatz' ], 'indikatorlaenge' => [ '1' ], 'satzlaenge' => [ '00296' ], 'teilfeldkennungslaenge' => [ '2' ] }, [ [ '001', ' ', '1000016-1', 'identifikationsnummer des datensatzes' ], [ '002', 'a', '19890418', 'datum der ersterfassung / fremddatenuebernahme' ], [ '004', ' ', '20010812', 'erstellungsdatum des austauschsatzes' ], ... [ '810', ' ', 'Accademia di San Luca <Roma, Accademia Nazionale di San Luca>', '1. verweisungsform zum namen der koerperschaft' ], [ '850', 'a', 'Reale Accademia di San Luca <Roma>', '1. frueherer, zeitweiser oder spaeterer name der koerper schaft' ], [ '852', 'a', '45335-3', '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.
Encode::MAB2
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.
Tie::MAB2::Recno
Tie::MAB2::Id
The tied objects have their stringifier overloaded to the as_string() method so that
as_string()
print $tie[1234];
always prints the record as the unaltered original input record.
Encode::MAB2, Tie::MAB2::Recno, Tie::MAB2::Id
To install Encode::MAB2, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Encode::MAB2
CPAN shell
perl -MCPAN -e shell install Encode::MAB2
For more information on module installation, please visit the detailed CPAN module installation guide.