/[MARC-Fast]/trunk/lib/MARC/Fast.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/MARC/Fast.pm

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

revision 46 by dpavlin, Thu Sep 23 13:15:01 2010 UTC revision 47 by dpavlin, Thu Aug 22 11:24:36 2013 UTC
# Line 7  use Data::Dump qw/dump/; Line 7  use Data::Dump qw/dump/;
7  BEGIN {  BEGIN {
8          use Exporter ();          use Exporter ();
9          use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);          use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
10          $VERSION     = 0.11;          $VERSION     = 0.12;
11          @ISA         = qw (Exporter);          @ISA         = qw (Exporter);
12          #Give a hoot don't pollute, do not export more than needed by default          #Give a hoot don't pollute, do not export more than needed by default
13          @EXPORT      = qw ();          @EXPORT      = qw ();
# Line 277  sub last_leader { Line 277  sub last_leader {
277    
278  Read record with specified MFN and convert it to hash  Read record with specified MFN and convert it to hash
279    
280    my $hash = $marc->to_hash( $mfn, include_subfields => 1, );    my $hash = $marc->to_hash( $mfn, include_subfields => 1,
281            hash_filter => sub { my ($l,$tag) = @_; return $l; }
282      );
283    
284  It has ability to convert characters (using C<hash_filter>) from MARC  It has ability to convert characters (using C<hash_filter>) from MARC
285  database before creating structures enabling character re-mapping or quick  database before creating structures enabling character re-mapping or quick
286  fix-up of data.  fix-up of data. If you specified C<hash_filter> both in C<new> and C<to_hash>
287    only the one from C<to_hash> will be used.
288    
289  This function returns hash which is like this:  This function returns hash which is like this:
290    
# Line 305  sub to_hash { Line 308  sub to_hash {
308          my $mfn = shift || confess "need mfn!";          my $mfn = shift || confess "need mfn!";
309    
310          my $args = {@_};          my $args = {@_};
311            my $filter_coderef = $args->{'hash_filter'} || $self->{'hash_filter'};
312    
313          # init record to include MFN as field 000          # init record to include MFN as field 000
314          my $rec = { '000' => [ $mfn ] };          my $rec = { '000' => [ $mfn ] };
# Line 318  sub to_hash { Line 322  sub to_hash {
322                          $l =~ s/\x1E$//;                          $l =~ s/\x1E$//;
323    
324                          # filter output                          # filter output
325                          $l = $self->{'hash_filter'}->($l, $tag) if ($self->{'hash_filter'});                          $l = $filter_coderef->($l, $tag) if $filter_coderef;
326    
327                          my $val;                          my $val;
328    

Legend:
Removed from v.46  
changed lines
  Added in v.47

  ViewVC Help
Powered by ViewVC 1.1.26