X-Git-Url: http://git.rot13.org/?p=MARC-Fast;a=blobdiff_plain;f=lib%2FMARC%2FFast.pm;h=3aa4c66d5a5564e912f7518ea12ae0d36e8486aa;hp=dc2f303e863bf7639065039517b0c46e1ab94190;hb=467b53f1a035f532af3fa75afc1fd522fdf6bba6;hpb=da0d66efdc1d4735f05935a6300a408e7f3ac503 diff --git a/lib/MARC/Fast.pm b/lib/MARC/Fast.pm index dc2f303..3aa4c66 100644 --- a/lib/MARC/Fast.pm +++ b/lib/MARC/Fast.pm @@ -7,7 +7,7 @@ use Data::Dump qw/dump/; BEGIN { use Exporter (); use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); - $VERSION = 0.11; + $VERSION = 0.12; @ISA = qw (Exporter); #Give a hoot don't pollute, do not export more than needed by default @EXPORT = qw (); @@ -277,11 +277,14 @@ sub last_leader { Read record with specified MFN and convert it to hash - my $hash = $marc->to_hash( $mfn, include_subfields => 1, ); + my $hash = $marc->to_hash( $mfn, include_subfields => 1, + hash_filter => sub { my ($l,$tag) = @_; return $l; } + ); It has ability to convert characters (using C) from MARC database before creating structures enabling character re-mapping or quick -fix-up of data. +fix-up of data. If you specified C both in C and C +only the one from C will be used. This function returns hash which is like this: @@ -305,6 +308,7 @@ sub to_hash { my $mfn = shift || confess "need mfn!"; my $args = {@_}; + my $filter_coderef = $args->{'hash_filter'} || $self->{'hash_filter'}; # init record to include MFN as field 000 my $rec = { '000' => [ $mfn ] }; @@ -318,7 +322,7 @@ sub to_hash { $l =~ s/\x1E$//; # filter output - $l = $self->{'hash_filter'}->($l, $tag) if ($self->{'hash_filter'}); + $l = $filter_coderef->($l, $tag) if $filter_coderef; my $val;