DOKK / manpages / debian 12 / libmarc-spec-perl / MARC::Spec.3pm.en
MARC::Spec(3pm) User Contributed Perl Documentation MARC::Spec(3pm)

MARC::Spec - A MARCspec parser and builder

    use MARC::Spec;
    
    # Parsing MARCspec from a string
    my $ms = MARC::Spec::parse('246[0-1]$f{245$h~\[microform\]|245$h~\microfilm}');
    # Structure
    say ref $ms;                                             # MARC::Spec
    say ref $ms->field;                                      # MARC::Spec::Field
    say ref $ms->subfields;                                  # ARRAY
    say ref $ms->subfields->[0];                             # MARC::Spec::Subfield
    say ref $ms->subfields->[0]->subspecs;                   # ARRAY
    say ref $ms->subfields->[0]->subspecs->[0];              # ARRAY
    say ref $ms->subfields->[0]->subspecs->[0]->[1];         # MARC::Spec::Subspec
    say ref $ms->subfields->[0]->subspecs->[0]->[1]->left;   # MARC::Spec
    say ref $ms->subfields->[0]->subspecs->[0]->[1]->right;  # MARC::Spec::Comparisonstring
    # Access to attributes
    say $ms->field->base;                                                    # 246[0-1]
    say $ms->field->tag;                                                     # 246
    say $ms->field->index_start;                                             # 0
    say $ms->field->index_end;                                               # 1
    say $ms->field->index_length;                                            # 2
    say $ms->subfields->[0]->base;                                           # 'f[0-#]'
    say $ms->subfields->[0]->code;                                           # 'f'
    say $ms->subfields->[0]->index_start;                                    # 0
    say $ms->subfields->[0]->index_end;                                      # '#'
    say $ms->subfields->[0]->subspecs->[0]->[0]->subterms;                   # '245$h~\[microform\]'
    say $ms->subfields->[0]->subspecs->[0]->[0]->left->field->tag;           # 245
    say $ms->subfields->[0]->subspecs->[0]->[0]->left->field->index_length;  # -1
    say $ms->subfields->[0]->subspecs->[0]->[0]->left->subfields->[0]->code; # 'h'
    say $ms->subfields->[0]->subspecs->[0]->[0]->right->comparable;          # '[microform]'
    say $ms->subfields->[0]->subspecs->[0]->[1]->right->comparable;          # 'microfilm'
    
    # creating MARCspec from scratch
    my $field    =  MARC::Spec::Field->new('245');
    my $subfield = MARC::Spec::Subfield->new('a');
    my $spec     = MARC::Spec->new($field);
    $spec->add_subfield($subfield);

MARC::Spec is a MARCspec - A common MARC record path language <http://marcspec.github.io/MARCspec/> parser and builder.

Parses a MARCspec as string and returns an instance of MARC::Spec.

Create a new MARC::Spec instance. Parameter must be an instance of MARC::Spec::Field.

Appends a subfield to the array of the attribute subfields. Parameter must be an instance of MARC::Spec::Subfield.

Appends subfields to the array of the attribute subfields. Parameter must be an ArrayRef and elements must be instances of MARC::Spec::Subfield.

Returns true if attribute subfields has an value and false otherwise.

Returns true if attribute indicator has an value and false otherwise.

Obligatory. Attribute field is an instance of MARC::Spec::Field.

If defined, subfields is an array of instances of MARC::Spec::Subfield.

If defined, indicator is an instance of MARC::Spec::Indicator.

Carsten Klee "<klee at cpan.org>"

Johann Rolschewski, "<jorol at cpan>"

This software is copyright (c) 2016 by Carsten Klee.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Please report any bugs to <https://github.com/MARCspec/MARC-Spec/issues>

  • MARC::Spec::Field
  • MARC::Spec::Subfield
  • MARC::Spec::Indicator
  • MARC::Spec::Subspec
  • MARC::Spec::Structure
  • MARC::Spec::Comparisonstring
  • MARC::Spec::Parser
2022-06-15 perl v5.34.0