The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MARC::Loader - Perl extension for creating MARC record from a hash

VERSION

Version 0.003001

SYNOPSIS

use MARC::Loader;
my $foo={
	'ldr' => 'optionnal_leader',
	'cleannsb' => 1,
	'f005_' => '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','francois']},
		{'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_content
# 101    _afre
#        _alat
#        _aspa
# 010    _d45
# 099 34 _c2011-02-03
#        _tLIVRE
# 200    _ale titre
# 215    _atest
# 700    _aICHER
#        _bfrancois
#        _bjean
#        _f1900-1950
# 700    _aPAULUS
#        _bMARIA
#        _f1353? - 1435
# 995    _bMP
#        _eS1
#        _f8002-ex
# 995    _eS2
#        _bMP
#        _f8001-ex

DESCRIPTION

This is a Perl extension for creating MARC records from a hash variable. MARC::Loader use MARC::Record.

The names of hash keys are very important.

They must begin with one letter ( e.g. f) followed by the 3-digit field ( e.g. 099) optionally followed by the letter or digit of the subfield. 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'] ). Control fields can't be repeatable and are automatically detected when the hash key begin with one letter followed by 3-digit lower than 10 followed by one letter or digit or underscore ( e.g. f005_). Indicators must begin with the letter i followed by the 3-digit field followed by the indicator's position (1 or 2) : e.g. i0991.

Record's leader can be defined with an hash key named '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);

    it's the only function you'll use.

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

1 POD Error

The following errors were encountered while parsing the POD:

Around line 272:

=over without closing =back