| 1 |
NAME |
| 2 |
|
| 3 |
MARC::Spec - A MARCspec parser and builder |
| 4 |
|
| 5 |
SYNOPSIS |
| 6 |
|
| 7 |
use MARC::Spec; |
| 8 |
|
| 9 |
# Parsing MARCspec from a string |
| 10 |
my $ms = MARC::Spec::parse('246[0-1]$f{245$h~\[microform\]|245$h~\microfilm}'); |
| 11 |
|
| 12 |
# Structure |
| 13 |
say ref $ms; # MARC::Spec |
| 14 |
say ref $ms->field; # MARC::Spec::Field |
| 15 |
say ref $ms->subfields; # ARRAY |
| 16 |
say ref $ms->subfields->[0]; # MARC::Spec::Subfield |
| 17 |
say ref $ms->subfields->[0]->subspecs; # ARRAY |
| 18 |
say ref $ms->subfields->[0]->subspecs->[0]; # ARRAY |
| 19 |
say ref $ms->subfields->[0]->subspecs->[0]->[1]; # MARC::Spec::Subspec |
| 20 |
say ref $ms->subfields->[0]->subspecs->[0]->[1]->left; # MARC::Spec |
| 21 |
say ref $ms->subfields->[0]->subspecs->[0]->[1]->right; # MARC::Spec::Comparisonstring |
| 22 |
|
| 23 |
# Access to attributes |
| 24 |
say $ms->field->base; # 246[0-1] |
| 25 |
say $ms->field->tag; # 246 |
| 26 |
say $ms->field->index_start; # 0 |
| 27 |
say $ms->field->index_end; # 1 |
| 28 |
say $ms->field->index_length; # 2 |
| 29 |
say $ms->subfields->[0]->base; # 'f[0-#]' |
| 30 |
say $ms->subfields->[0]->code; # 'f' |
| 31 |
say $ms->subfields->[0]->index_start; # 0 |
| 32 |
say $ms->subfields->[0]->index_end; # '#' |
| 33 |
say $ms->subfields->[0]->subspecs->[0]->[0]->subterms; # '245$h~\[microform\]' |
| 34 |
say $ms->subfields->[0]->subspecs->[0]->[0]->left->field->tag; # 245 |
| 35 |
say $ms->subfields->[0]->subspecs->[0]->[0]->left->field->index_length; # -1 |
| 36 |
say $ms->subfields->[0]->subspecs->[0]->[0]->left->subfields->[0]->code; # 'h' |
| 37 |
say $ms->subfields->[0]->subspecs->[0]->[0]->right->comparable; # '[microform]' |
| 38 |
say $ms->subfields->[0]->subspecs->[0]->[1]->right->comparable; # 'microfilm' |
| 39 |
|
| 40 |
# creating MARCspec from scratch |
| 41 |
my $field = MARC::Spec::Field->new('245'); |
| 42 |
my $subfield = MARC::Spec::Subfield->new('a'); |
| 43 |
my $spec = MARC::Spec->new($field); |
| 44 |
$spec->add_subfield($subfield); |
| 45 |
|
| 46 |
DESCRIPTION |
| 47 |
|
| 48 |
MARC::Spec is a MARCspec - A common MARC record path language |
| 49 |
<http://marcspec.github.io/MARCspec/> parser and builder. |
| 50 |
|
| 51 |
FUNCTIONS |
| 52 |
|
| 53 |
parse(Str) |
| 54 |
|
| 55 |
Parses a MARCspec as string and returns an instance of MARC::Spec. |
| 56 |
|
| 57 |
METHODS |
| 58 |
|
| 59 |
new(MARC::Spec::Field) |
| 60 |
|
| 61 |
Create a new MARC::Spec instance. Parameter must be an instance of |
| 62 |
MARC::Spec::Field. |
| 63 |
|
| 64 |
add_subfield(MARC::Spec::Subfield) |
| 65 |
|
| 66 |
Appends a subfield to the array of the attribute subfields. Parameter |
| 67 |
must be an instance of MARC::Spec::Subfield. |
| 68 |
|
| 69 |
add_subfields(ArrayRef[MARC::Spec::Subfield]) |
| 70 |
|
| 71 |
Appends subfields to the array of the attribute subfields. Parameter |
| 72 |
must be an ArrayRef and elements must be instances of |
| 73 |
MARC::Spec::Subfield. |
| 74 |
|
| 75 |
PREDICATES |
| 76 |
|
| 77 |
has_subfields |
| 78 |
|
| 79 |
Returns true if attribute subfields has an value and false otherwise. |
| 80 |
|
| 81 |
has_indicator |
| 82 |
|
| 83 |
Returns true if attribute indicator has an value and false otherwise. |
| 84 |
|
| 85 |
ATTRIBUTES |
| 86 |
|
| 87 |
field |
| 88 |
|
| 89 |
Obligatory. Attribute field is an instance of MARC::Spec::Field. |
| 90 |
|
| 91 |
subfields |
| 92 |
|
| 93 |
If defined, subfields is an array of instances of MARC::Spec::Subfield. |
| 94 |
|
| 95 |
indicator |
| 96 |
|
| 97 |
If defined, indicator is an instance of MARC::Spec::Indicator. |
| 98 |
|
| 99 |
AUTHOR |
| 100 |
|
| 101 |
Carsten Klee <klee at cpan.org> |
| 102 |
|
| 103 |
CONTRIBUTORS |
| 104 |
|
| 105 |
* Johann Rolschewski, <jorol at cpan> |
| 106 |
|
| 107 |
COPYRIGHT AND LICENSE |
| 108 |
|
| 109 |
This software is copyright (c) 2016 by Carsten Klee. |
| 110 |
|
| 111 |
This is free software; you can redistribute it and/or modify it under |
| 112 |
the same terms as the Perl 5 programming language system itself. |
| 113 |
|
| 114 |
BUGS |
| 115 |
|
| 116 |
Please report any bugs to https://github.com/MARCspec/MARC-Spec/issues |
| 117 |
|
| 118 |
SEE ALSO |
| 119 |
|
| 120 |
* MARC::Spec::Field |
| 121 |
|
| 122 |
* MARC::Spec::Subfield |
| 123 |
|
| 124 |
* MARC::Spec::Indicator |
| 125 |
|
| 126 |
* MARC::Spec::Subspec |
| 127 |
|
| 128 |
* MARC::Spec::Structure |
| 129 |
|
| 130 |
* MARC::Spec::Comparisonstring |
| 131 |
|
| 132 |
* MARC::Spec::Parser |
| 133 |
|