/[webpac2]/trunk/lib/WebPAC/Input/MARC.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/WebPAC/Input/MARC.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 307 - (hide annotations)
Tue Dec 20 00:03:04 2005 UTC (18 years, 4 months ago) by dpavlin
File size: 1491 byte(s)
moved clean into WebPAC::Output::Estraier, cleanup

1 dpavlin 289 package WebPAC::Input::MARC;
2    
3     use warnings;
4     use strict;
5    
6     use MARC::Fast;
7    
8     =head1 NAME
9    
10     WebPAC::Input::MARC - support for MARC database files
11    
12     =head1 VERSION
13    
14 dpavlin 298 Version 0.02
15 dpavlin 289
16     =cut
17    
18 dpavlin 298 our $VERSION = '0.02';
19 dpavlin 289
20    
21     =head1 SYNOPSIS
22    
23     Open USMARC, Unimarc or any other file format that has same internal
24     structure using C<MARC::Fast>.
25    
26     my $marc = new WebPAC::Input::MARC();
27     $marc->open( path => '/path/to/marc.iso' );
28    
29     =head1 FUNCTIONS
30    
31     =head2 open_db
32    
33     Returns handle to database
34    
35     my $db = $open_db(
36     path => '/path/to/marc.iso'
37     }
38    
39     =cut
40    
41     sub open_db {
42     my $self = shift;
43    
44     my $arg = {@_};
45    
46     my $log = $self->_get_logger();
47    
48     $log->info("opening MARC database '$arg->{path}'");
49    
50     my $db = new MARC::Fast( marcdb => $arg->{path});
51 dpavlin 290 my $db_size = $db->count - 1; # FIXME
52 dpavlin 289
53 dpavlin 290 $self->{size} = $db_size;
54    
55 dpavlin 289 return ($db, $db_size);
56     }
57    
58     =head2 fetch_rec
59    
60     Return record with ID C<$mfn> from database
61    
62     my $rec = $self->fetch_rec( $db, $mfn );
63    
64     }
65    
66     =cut
67    
68     sub fetch_rec {
69     my $self = shift;
70    
71     my ($db, $mfn) = @_;
72    
73 dpavlin 290 if ($mfn > $self->{size}) {
74     $self->_get_logger()->warn("seek beyond database size $self->{size} to $mfn");
75     } else {
76     my $row = $db->fetch($mfn);
77 dpavlin 291 push @{$row->{'000'}}, $mfn;
78 dpavlin 290 return $row;
79     }
80 dpavlin 289 }
81    
82     =head1 AUTHOR
83    
84     Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
85    
86     =head1 COPYRIGHT & LICENSE
87    
88     Copyright 2005 Dobrica Pavlinusic, All Rights Reserved.
89    
90     This program is free software; you can redistribute it and/or modify it
91     under the same terms as Perl itself.
92    
93     =cut
94    
95     1; # End of WebPAC::Input::MARC

  ViewVC Help
Powered by ViewVC 1.1.26