1 package WebPAC::Input::MARC;
10 WebPAC::Input::MARC - support for MARC database files
18 our $VERSION = '0.05';
23 Open USMARC, Unimarc or any other file format that has same internal
24 structure using C<MARC::Fast>.
26 my $marc = new WebPAC::Input::MARC();
27 $marc->open( path => '/path/to/marc.iso' );
33 Returns handle to database and size in records
35 my ($db,$size) = $open_db(
36 path => '/path/to/marc.iso',
47 my $log = $self->_get_logger();
49 $log->info("opening MARC database '$arg->{path}'");
51 my $db = new MARC::Fast(
52 marcdb => $arg->{path},
53 hash_filter => $arg->{filter},
55 my $db_size = $db->count - 1; # FIXME
57 $self->{_marc_size} = $db_size;
58 $self->{_marc_db} = $db;
60 return ($db, $db_size);
65 Return record with ID C<$mfn> from database
67 my $rec = $self->fetch_rec( $mfn );
78 if ($mfn > $self->{_marc_size}) {
79 $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
81 my $row = $self->{_marc_db}->to_hash($mfn);
82 push @{$row->{'000'}}, $mfn;
91 Store size of MARC database
93 print $self->{_marc_size};
99 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
101 =head1 COPYRIGHT & LICENSE
103 Copyright 2005 Dobrica Pavlinusic, All Rights Reserved.
105 This program is free software; you can redistribute it and/or modify it
106 under the same terms as Perl itself.
110 1; # End of WebPAC::Input::MARC