/[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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 307 by dpavlin, Tue Dec 20 00:03:04 2005 UTC revision 497 by dpavlin, Sun May 14 19:45:36 2006 UTC
# Line 3  package WebPAC::Input::MARC; Line 3  package WebPAC::Input::MARC;
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6  use MARC::Fast;  use MARC::Fast 0.03;
7    
8  =head1 NAME  =head1 NAME
9    
# Line 11  WebPAC::Input::MARC - support for MARC d Line 11  WebPAC::Input::MARC - support for MARC d
11    
12  =head1 VERSION  =head1 VERSION
13    
14  Version 0.02  Version 0.05
15    
16  =cut  =cut
17    
18  our $VERSION = '0.02';  our $VERSION = '0.05';
19    
20    
21  =head1 SYNOPSIS  =head1 SYNOPSIS
# Line 30  structure using C<MARC::Fast>. Line 30  structure using C<MARC::Fast>.
30    
31  =head2 open_db  =head2 open_db
32    
33  Returns handle to database  Returns handle to database and size in records
34    
35    my $db = $open_db(    my ($db,$size) = $open_db(
36          path => '/path/to/marc.iso'          path => '/path/to/marc.iso',
37            filter => \&code_ref,
38    }    }
39    
40  =cut  =cut
# Line 47  sub open_db { Line 48  sub open_db {
48    
49          $log->info("opening MARC database '$arg->{path}'");          $log->info("opening MARC database '$arg->{path}'");
50    
51          my $db = new MARC::Fast( marcdb => $arg->{path});          my $db = new MARC::Fast(
52                    marcdb => $arg->{path},
53                    hash_filter => $arg->{filter},
54            );
55          my $db_size = $db->count - 1;   # FIXME          my $db_size = $db->count - 1;   # FIXME
56    
57          $self->{size} = $db_size;          $self->{_marc_size} = $db_size;
58    
59          return ($db, $db_size);          return ($db, $db_size);
60  }  }
# Line 70  sub fetch_rec { Line 74  sub fetch_rec {
74    
75          my ($db, $mfn) = @_;          my ($db, $mfn) = @_;
76    
77          if ($mfn > $self->{size}) {          if ($mfn > $self->{_marc_size}) {
78                  $self->_get_logger()->warn("seek beyond database size $self->{size} to $mfn");                  $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
79          } else {          } else {
80                  my $row = $db->fetch($mfn);                  my $row = $db->to_hash($mfn);
81                  push @{$row->{'000'}}, $mfn;                  push @{$row->{'000'}}, $mfn;
82                  return $row;                  return $row;
83          }          }
84  }  }
85    
86    =head1 PROPERTIES
87    
88    =head2 _marc_size
89    
90    Store size of MARC database
91    
92      print $self->{_marc_size};
93    
94    
95    
96  =head1 AUTHOR  =head1 AUTHOR
97    
98  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>

Legend:
Removed from v.307  
changed lines
  Added in v.497

  ViewVC Help
Powered by ViewVC 1.1.26