/[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 298 - (hide annotations)
Mon Dec 19 19:55:21 2005 UTC (18 years, 5 months ago) by dpavlin
File size: 1502 byte(s)
 r317@athlon:  dpavlin | 2005-12-19 20:56:26 +0100
 some fixes and cleanup, moved module versions to Makefile.PL

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

  ViewVC Help
Powered by ViewVC 1.1.26