/[Biblio-Isis]/trunk/lib/Biblio/Isis.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/Biblio/Isis.pm

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

revision 63 by dpavlin, Mon Jul 10 12:01:04 2006 UTC revision 64 by dpavlin, Thu Jul 13 13:27:27 2006 UTC
# Line 84  Open ISIS database Line 84  Open ISIS database
84          read_fdt => 1,          read_fdt => 1,
85          include_deleted => 1,          include_deleted => 1,
86          hash_filter => sub {          hash_filter => sub {
87                  my $v = shift;                  my ($v,$field_number) = @_;
88                  $v =~ s#foo#bar#g;                  $v =~ s#foo#bar#g;
89          },          },
90          debug => 1,          debug => 1,
91          join_subfields_with => ' ; ',          join_subfields_with => ' ; ',
         regexps => [  
                 's/something/else/g',  
         ],  
92   );   );
93    
94  Options are described below:  Options are described below:
# Line 129  Define delimiter which will be used to j Line 126  Define delimiter which will be used to j
126  option is included to support lagacy application written against version  option is included to support lagacy application written against version
127  older than 0.21 of this module. By default, it disabled. See L</to_hash>.  older than 0.21 of this module. By default, it disabled. See L</to_hash>.
128    
 =item regexpes  
   
 Define (any number) of regexpes to apply at field values before they are  
 splitted into subfield. This is great place to split subfields in input to  
 mulitple subfields if needed or rename subfields.  
   
129  =back  =back
130    
131  =cut  =cut
# Line 528  There is also more elaborative way to ca Line 519  There is also more elaborative way to ca
519    my $hash = $isis->to_hash({    my $hash = $isis->to_hash({
520          mfn => 42,          mfn => 42,
521          include_subfields => 1,          include_subfields => 1,
         regexps => [  
                 's/something/else/g',  
         ],  
522    });    });
523    
524  Each option controll creation of hash:  Each option controll creation of hash:
# Line 558  have original record subfield order and Line 546  have original record subfield order and
546  Define delimiter which will be used to join repeatable subfields. You can  Define delimiter which will be used to join repeatable subfields. You can
547  specify option here instead in L</new> if you want to have per-record control.  specify option here instead in L</new> if you want to have per-record control.
548    
 =item regexpes  
   
 Override C<regexpes> specified in L</new>.  
   
549  =back  =back
550    
551  =cut  =cut
# Line 578  sub to_hash { Line 562  sub to_hash {
562                  $mfn = $arg->{mfn} || confess "need mfn in arguments";                  $mfn = $arg->{mfn} || confess "need mfn in arguments";
563          }          }
564    
         $arg->{regexpes} ||= $self->{regexpes};  
   
         confess "regexps must be HASH" if ($arg->{regexps} && ref($arg->{regexps}) ne 'HASH');  
   
565          # init record to include MFN as field 000          # init record to include MFN as field 000
566          my $rec = { '000' => [ $mfn ] };          my $rec = { '000' => [ $mfn ] };
567    
# Line 596  sub to_hash { Line 576  sub to_hash {
576    
577                          # filter output                          # filter output
578                          if ($self->{'hash_filter'}) {                          if ($self->{'hash_filter'}) {
579                                  $l = $self->{'hash_filter'}->($l);                                  $l = $self->{'hash_filter'}->($l, $f_nr);
580                                  next unless defined($l);                                  next unless defined($l);
581                          }                          }
582    
                         # apply regexps  
                         if ($arg->{regexps} && defined($arg->{regexps}->{$f_nr})) {  
                                 confess "regexps->{$f_nr} must be ARRAY" if (ref($arg->{regexps}->{$f_nr}) ne 'ARRAY');  
                                 my $c = 0;  
                                 foreach my $r (@{ $arg->{regexps}->{$f_nr} }) {  
                                         while ( eval '$l =~ ' . $r ) { $c++ };  
                                 }  
                                 warn "## field $f_nr triggered $c regexpes\n" if ($c && $self->{debug});  
                         }  
   
583                          my $val;                          my $val;
584                          my $r_sf;       # repeatable subfields in this record                          my $r_sf;       # repeatable subfields in this record
585    

Legend:
Removed from v.63  
changed lines
  Added in v.64

  ViewVC Help
Powered by ViewVC 1.1.26