/usr/share/perl5/Catmandu/Importer/MARC.pm is in libcatmandu-marc-perl 0.214-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | =head1 NAME
Catmandu::Importer::MARC - Package that imports MARC data
=head1 SYNOPSIS
# From the command line
$ catmandu convert MARC --fix "marc_map('245a','title')" < /foo/bar.mrc
# From Perl
use Catmandu;
# import records from file
my $importer = Catmandu->importer('MARC',file => '/foo/bar.mrc');
my $fixer = Catmandu->fixer("marc_map('245a','title')");
$importer->each(sub {
my $item = shift;
...
});
# or using the fixer
$fixer->fix($importer)->each(sub {
my $item = shift;
printf "title: %s\n" , $item->{title};
});
=head1 DESCRIPTION
Catmandu::Importer::MARC is a L<Catmandu::Iterable> to import MARC records from an
external source. When given an input file an Catmandu::Iterable is create generating
items as perl HASH-es containing two keys:
'_id' : the system identifier of the record (usually the 001 field)
'record' : an ARRAY of ARRAYs containing the record data
Read more about processing data with Catmandu on the wiki: L<https://github.com/LibreCat/Catmandu/wiki>
=head1 EXAMPLE ITEM
{
'record' => [
[
'001',
undef,
undef,
'_',
'fol05882032 '
],
[
'245',
'1',
'0',
'a',
'Cross-platform Perl /',
'c',
'Eric F. Johnson.'
],
],
'_id' => 'fol05882032'
}
=head1 METHODS
=head2 new(file => $filename, type => $type)
Create a new MARC importer for $filename. Use STDIN when no filename is given.
Type describes the MARC parser to be used. Currently we support:
=over 2
=item USMARC L<Catmandu::Importer::MARC::USMARC>
=item MicroLIF L<Catmandu::Importer::MARC::MicroLIF>
=item MARCMaker L<Catmandu::Importer::MARC::MARCMaker>
=item JSON L<Catmandu::Importer::MARC::MiJ>
=item XML L<Catmandu::Importer::MARC::XML>
=item RAW L<Catmandu::Importer::MARC::RAW>
=item Lint L<Catmandu::Importer::MARC::Lint>
=item ALEPHSEQ L<Catmandu::Importer::MARC::ALEPHSEQ>
=back
Read the documentation of the parser modules for extra configuration options.
=head1 INHERTED METHODS
=head2 count
=head2 each(&callback)
=head2 ...
Every L<Catmandu::Importer> is a L<Catmandu::Iterable> all its methods are inherited.
=head1 SEE ALSO
L<Catmandu::Importer>,
L<Catmandu::Iterable>,
L<Catmandu::Fix::marc_map> ,
L<Catmandu::Fix::marc_xml>
=cut
package Catmandu::Importer::MARC;
use Catmandu::Sane;
use Catmandu::Util;
use Moo;
has type => (is => 'ro' , default => sub { 'USMARC' });
has _importer => (is => 'ro' , lazy => 1 , builder => '_build_importer' , handles => 'Catmandu::Importer');
has _importer_args => (is => 'rwp', writer => '_set_importer_args');
sub _build_importer {
my ($self) = @_;
my $type = $self->type;
$type = 'Record' if exists $self->_importer_args->{records};
my $pkg = Catmandu::Util::require_package($type,'Catmandu::Importer::MARC');
$pkg->new($self->_importer_args);
}
sub BUILD {
my ($self,$args) = @_;
$self->_set_importer_args($args);
}
1;
|