NAME
MARC::Loader - Perl module for creating MARC record from a hash
VERSION
Version 0.004001
SYNOPSIS
use MARC::Loader;my $foo={'ldr' => 'optionnal_leader','cleannsb' => 1,'f005' => [{'f005_' => 'controlfield_contenta'},{'f005_' => 'controlfield_contentb'}],'f006_' => 'controlfield_content','f010d' => '45','f099c' => '2011-02-03','f099t' => 'LIVRE','i0991' => '3','i0992' => '4','f200a' => "\x88le \x89titre",'001##f101a' => ['lat','fre','spa'],'f215a' => [ 'test' ],'f700' => [{'f700f' => '1900-1950','f700a' => 'ICHER','f700b' => ['jean','francis']},{'f700f' => '1353? - 1435','f700a' => 'PAULUS','f700b' => 'MARIA'}],'f995' => [{'f995e' => 'S1','f995b' => 'MP','f995f' => '8002-ex'},{'001##f995e' => 'S2','002##f995b' => 'MP','005##f995f' => '8001-ex'}]};my $record = MARC::Loader->new($foo);# Here, the command "print $record->as_formatted;" will return :# LDR optionnal_leader# 005 controlfield_contenta# 005 controlfield_contentb# 006 controlfield_content# 101 _afre# _alat# _aspa# 010 _d45# 099 34 _c2011-02-03# _tLIVRE# 200 _ale titre# 215 _atest# 700 _aICHER# _bfrancis# _bjean# _f1900-1950# 700 _aPAULUS# _bMARIA# _f1353? - 1435# 995 _bMP# _eS1# _f8002-ex# 995 _eS2# _bMP# _f8001-ex
DESCRIPTION
This is a Perl module for creating MARC records from a hash variable. MARC::Loader use MARC::Record.
Hash keys naming convention.
The names of hash keys are very important. They must begin with letter f followed by the 3-digit field name ( e.g. f099), followed, for the subfields, by their letter or digit ( e.g. f501b).
Repeatable fields are arrays of hash ( e.g., 'f700' => [{'f700f' => '1900','f700a' => 'ICHER'},{'f700f' => '1353','f700a' => 'PAULUS'}] ).
Repeatable subfields are arrays ( e.g., 'f101a' => [ 'lat','fre','spa'] ).
Controlfields are automatically detected when the hash key begin with letter f followed by 3-digit lower than 10 followed by underscore ( e.g. f005_).
Indicators must begin with the letter i followed by the 3-digit field name followed by the indicator's position (1 or 2) : e.g. "i0991".
Record's leader can be defined with the hash key 'ldr' ( e.g., 'ldr' => 1 ).
reorder fields and subfields
Fields and subfields are in lexically order. If you want reorder fields and subfields differently, you can add a reordering string (necessarily followed by ##) at the beginning of hash keys (e.g., to reorder the subfields of f995 to have $e followed by $b : 'f995' => [{'001##f995e' => 'S2','002##f995b' => 'MP')]};). If you want to reorder fields, please note that the controlfields will always be located before the other (e.g., if you define '001##f101a' => [ 'lat','fre','spa'] , the f101 will be placed after the last controlfield ).
Be careful, the reorder is made lexically, not numerically : 10 will be placed before 2, while 002 will be placed before 010.
If the script you use to build your hash requires you to precede fields AND subfields with a reordering string when you want to reorder only those sub-fields, you can force the module to reorder the fields in alphabetical order with an hash key named 'orderfields' ( e.g., 'orderfields' => 1 ).
You can also remove non-sorting characters with an hash key named 'cleannsb' ( e.g., 'cleannsb' => 1 ).
METHOD
new()
- •
-
$record= MARC::Loader->new($foo);This is the only method provided by the module.
AUTHOR
Stephane Delaune, (delaune.stephane at gmail.com)
COPYRIGHT
Copyright 2011 Stephane Delaune for Biblibre.com, all rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
- •
-
MARC::Record (<http://search.cpan.org/~gmcharlt/MARC-Record/lib/MARC/Record.pm>)
- •
-
MARC::Field (<http://search.cpan.org/~gmcharlt/MARC-Record/lib/MARC/Field.pm>)
- •
-
Library Of Congress MARC pages (<http://www.loc.gov/marc/>)
The definitive source for all things MARC.