Catmandu-MARC
view release on metacpan or search on metacpan
lib/Catmandu/Fix/marc_spec.pm view on Meta::CPAN
=head2 marc_spec(MARCspec, JSON_PATH, OPT:VAL, OPT2:VAL,...)
First parameter must be a string, following the syntax of
L<MARCspec - A common MARC record path language|http://marcspec.github.io/MARCspec/>.
Do always use single quotes with this first parameter.
Second parameter is a string describing the variable or the variable path
to assign referenced values to
(see L<Catmandu Paths|http://librecat.org/Catmandu/#paths>).
You may use one of $first, $last, $prepend or $append to add
referenced data values to a specific position of an array
(see L<Catmandu Wildcards|http://librecat.org/Catmandu/#wildcards> and
mapping rules at L<https://github.com/LibreCat/Catmandu-MARC/wiki/Mapping-rules>).
# INPUT
[245,1,0,"a","Cross-platform Perl /","c","Eric F. Johnson."]
# CALL
marc_spec('245', my.title.$append)
# OUTPUT
{
my {
title [
[0] "Cross-platform Perl /Eric F. Johnson."
]
}
}
Third and every other parameters are optional and must
be in the form of key:value (see L</"OPTIONS"> for a deeper
understanding of options).
=head1 OPTIONS
=head2 split: 0|1
If split is set to 1, every fixed fields value or every subfield will be
an array element.
# INPUT
[650," ",0,"a","Perl (Computer program language)"],
[650," ",0,"a","Web servers."]
# CALL
marc_spec('650', my.subjects, split:1)
# OUTPUT
{
my {
subjects [
[0] "Perl (Computer program language)",
[1] "Web servers."
]
}
}
See split mapping rules at L<https://github.com/LibreCat/Catmandu-MARC/wiki/Mapping-rules>.
=head2 nested_arrays: 0|1
Using the nested_array
option the output will be an array of array of strings (one array item for
each matched field, one array of strings for each matched subfield).
# INPUT
[650," ",0,"a","Perl (Computer program language)"],
[650," ",0,"a","Web servers."]
# CALL
marc_spec('650', my.subjects, nested_arrays:1)
# OUTPUT
{
my {
subjects [
[0] [
[0] "Perl (Computer program language)"
]
[1] [
[0] "Web servers."
]
]
}
}
See nested_array mapping rules at L<https://github.com/LibreCat/Catmandu-MARC/wiki/Mapping-rules>.
=head2 join: Str
If set, value of join will be used to join the referenced data content.
This will only have an effect if option split is undefined (not set or set to 0).
# INPUT
[650," ",0,"a","Perl (Computer program language)"],
[650," ",0,"a","Web servers."]
# CALL
marc_spec('650', my.subjects, join:'###')
# OUTPUT
{
my {
subjects "Perl (Computer program language)###Web servers."
}
}
=head2 pluck: 0|1
This has only an effect on subfield values. By default subfield reference
happens in 'natural' order (first number 0 to 9 and then letters a to z).
# INPUT
["020"," ", " ","a","0491001304","q","black leather"]
# CALL
marc_spec('020$q$a', my.isbn, split:1)
( run in 1.027 second using v1.01-cache-2.11-cpan-af0e5977854 )