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',
52 my $log = $self->_get_logger();
54 $log->info("opening MARC database '$arg->{path}'");
56 my $db = new MARC::Fast(
57 marcdb => $arg->{path},
58 hash_filter => $arg->{filter},
60 my $db_size = $db->count - 1; # FIXME
62 $self->{_marc_size} = $db_size;
63 $self->{_marc_db} = $db;
65 $self ? return $self : return undef;
70 Return record with ID C<$mfn> from database
72 my $rec = $self->fetch_rec( $mfn );
83 if ($mfn > $self->{_marc_size}) {
84 $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
86 my $marc = $self->{_marc_db} || confess "no _marc_db?";
87 my $row = $marc->to_hash($mfn);
88 push @{$row->{'000'}}, $mfn;
89 push @{$row->{'leader'}}, $marc->last_leader;
96 Return ASCII dump of record with ID C<$mfn> from database
98 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