/[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 1063 by dpavlin, Tue Nov 27 21:01:44 2007 UTC revision 1327 by dpavlin, Tue Feb 9 20:14:23 2010 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 0.03;  use MARC::Fast;
7  use base qw/WebPAC::Common/;  use base qw/WebPAC::Common/;
8  use Carp qw/confess/;  use Carp qw/confess/;
9    
# Line 37  Returns new low-level input API object Line 37  Returns new low-level input API object
37    
38    my $marc = new WebPAC::Input::MARC(    my $marc = new WebPAC::Input::MARC(
39          path => '/path/to/marc.iso',          path => '/path/to/marc.iso',
         filter => \&code_ref,  
40    }    }
41    
42  =cut  =cut
# Line 53  sub new { Line 52  sub new {
52    
53          $log->info("opening MARC database '$arg->{path}'");          $log->info("opening MARC database '$arg->{path}'");
54    
55            die "no filter support any more!" if $arg->{filter};
56    
57          my $db = new MARC::Fast(          my $db = new MARC::Fast(
58                  marcdb => $arg->{path},                  marcdb => $arg->{path},
59                  hash_filter => $arg->{filter},                  hash_filter => sub {
60                            my ( $l, $nr ) = @_;
61                            Encode::decode( 'utf-8', $l );
62                    },
63          );          );
64          my $db_size = $db->count - 1;   # FIXME          my $db_size = $db->count - 1;   # FIXME
65    
# Line 82  sub fetch_rec { Line 86  sub fetch_rec {
86                  $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");                  $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
87          } else {          } else {
88                  my $marc = $self->{_marc_db} || confess "no _marc_db?";                  my $marc = $self->{_marc_db} || confess "no _marc_db?";
89                  my $row = $marc->to_hash($mfn);                  my $row = $marc->to_hash($mfn, include_subfields => 1);
90                  push @{$row->{'000'}}, $mfn;                  push @{$row->{'000'}}, $mfn;
91                  push @{$row->{'leader'}}, $marc->last_leader;                  push @{$row->{'leader'}}, $marc->last_leader;
92                  return $row;                  return $row;

Legend:
Removed from v.1063  
changed lines
  Added in v.1327

  ViewVC Help
Powered by ViewVC 1.1.26