From: Dobrica Pavlinusic Date: Thu, 22 Aug 2013 12:02:58 +0000 (+0200) Subject: Added hash_filter when using MARC::Fast 0.12 X-Git-Url: http://git.rot13.org/?p=webpac2;a=commitdiff_plain;h=0f28ff5a71e21a2a57a1e448123a27eaaabd6faa;hp=7231c84972bb18eef741860717bf0320ea567610 Added hash_filter when using MARC::Fast 0.12 This enables modify_file to work with MARC inputs --- diff --git a/Makefile.PL b/Makefile.PL index 358dee5..c6499cb 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -22,7 +22,7 @@ requires 'Encode'; requires 'LWP'; requires 'File::Path'; requires 'Biblio::Isis' => '0.24'; -requires 'MARC::Fast' => '0.11'; +requires 'MARC::Fast' => '0.12'; requires 'List::Util'; requires 'MARC::Record' => '2.0'; requires 'Data::Dump'; diff --git a/lib/WebPAC/Input/MARC.pm b/lib/WebPAC/Input/MARC.pm index c5f7b30..6002320 100644 --- a/lib/WebPAC/Input/MARC.pm +++ b/lib/WebPAC/Input/MARC.pm @@ -3,7 +3,7 @@ package WebPAC::Input::MARC; use warnings; use strict; -use MARC::Fast; +use MARC::Fast 0.12; use base qw/WebPAC::Common/; use Carp qw/confess/; @@ -56,10 +56,6 @@ sub new { my $db = new MARC::Fast( marcdb => $arg->{path}, - hash_filter => sub { - my ( $l, $nr ) = @_; - Encode::decode( 'utf-8', $l ); - }, ); my $db_size = $db->count - 1; # FIXME @@ -80,13 +76,13 @@ Return record with ID C<$mfn> from database sub fetch_rec { my $self = shift; - my $mfn = shift; + my ($mfn, $filter_coderef) = @_; if ($mfn > $self->{_marc_size}) { $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn"); } else { my $marc = $self->{_marc_db} || confess "no _marc_db?"; - my $row = $marc->to_hash($mfn, include_subfields => 1); + my $row = $marc->to_hash($mfn, include_subfields => 1, hash_filter => $filter_coderef); push @{$row->{'000'}}, $mfn; push @{$row->{'leader'}}, $marc->last_leader; return $row;