1 package WebPAC::Input::MARC;
7 use base qw/WebPAC::Common/;
12 WebPAC::Input::MARC - support for MARC database files
20 our $VERSION = '0.09';
25 Open USMARC, Unimarc or any other file format that has same internal
26 structure using C<MARC::Fast>.
28 my $marc = new WebPAC::Input::MARC(
29 path => '/path/to/marc.iso'
36 Returns new low-level input API object
38 my $marc = new WebPAC::Input::MARC(
39 path => '/path/to/marc.iso',
51 my $log = $self->_get_logger();
53 $log->info("opening MARC database '$arg->{path}'");
55 die "no filter support any more!" if $arg->{filter};
57 my $db = new MARC::Fast(
58 marcdb => $arg->{path},
61 Encode::decode( 'utf-8', $l );
64 my $db_size = $db->count - 1; # FIXME
66 $self->{_marc_size} = $db_size;
67 $self->{_marc_db} = $db;
69 $self ? return $self : return undef;
74 Return record with ID C<$mfn> from database
76 my $rec = $self->fetch_rec( $mfn );
85 if ($mfn > $self->{_marc_size}) {
86 $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
88 my $marc = $self->{_marc_db} || confess "no _marc_db?";
89 my $row = $marc->to_hash($mfn, include_subfields => 1);
90 push @{$row->{'000'}}, $mfn;
91 push @{$row->{'leader'}}, $marc->last_leader;
98 Return ASCII dump of record with ID C<$mfn> from database
100 print $self->dump_ascii( $mfn );
108 return $self->{_marc_db}->to_ascii($mfn);
113 Return number of records in database
115 my $size = $isis->size;
121 return $self->{_marc_size};
127 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
129 =head1 COPYRIGHT & LICENSE
131 Copyright 2005 Dobrica Pavlinusic, All Rights Reserved.
133 This program is free software; you can redistribute it and/or modify it
134 under the same terms as Perl itself.
138 1; # End of WebPAC::Input::MARC