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

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

revision 1046 by dpavlin, Mon Nov 12 14:18:49 2007 UTC revision 1047 by dpavlin, Mon Nov 19 15:56:05 2007 UTC
# Line 136  sub marc_template { Line 136  sub marc_template {
136    
137          foreach my $r ( @$from_rec ) {          foreach my $r ( @$from_rec ) {
138    
                 my $i1 = $r->{i1} || ' ';  
                 my $i2 = $r->{i2} || ' ';  
139                  my $to = $args->{to};                  my $to = $args->{to};
140                    my ($i1,$i2) = _get_marc_indicators( $to );
141                  $m = [ $to, $i1, $i2 ];                  $m = [ $to, $i1, $i2 ];
142    
143                  $created_with_marc_template->{ $to }++;                  $created_with_marc_template->{ $to }++;
# Line 346  sub marc { Line 345  sub marc {
345          foreach (@_) {          foreach (@_) {
346                  my $v = $_;             # make var read-write for Encode                  my $v = $_;             # make var read-write for Encode
347                  next unless (defined($v) && $v !~ /^\s*$/);                  next unless (defined($v) && $v !~ /^\s*$/);
348                  my ($i1,$i2) = defined($marc_indicators->{$f}) ? @{ $marc_indicators->{$f} } : (' ',' ');                  my ($i1,$i2) = _get_marc_indicators( $f );
349                  if (defined $sf) {                  if (defined $sf) {
350                          push @{ $marc_record->[ $marc_record_offset ] }, [ $f, $i1, $i2, $sf => $v ];                          push @{ $marc_record->[ $marc_record_offset ] }, [ $f, $i1, $i2, $sf => $v ];
351                  } else {                  } else {
# Line 391  sub marc_indicators { Line 390  sub marc_indicators {
390          @{ $marc_indicators->{$f} } = ($i1,$i2);          @{ $marc_indicators->{$f} } = ($i1,$i2);
391  }  }
392    
393    sub _get_marc_indicators {
394            my $f = shift || confess "need field!\n";
395            return defined($marc_indicators->{$f}) ? @{ $marc_indicators->{$f} } : (' ',' ');
396    }
397    
398  =head2 marc_compose  =head2 marc_compose
399    
400  Save values for each MARC subfield explicitly  Save values for each MARC subfield explicitly
# Line 411  sub marc_compose { Line 415  sub marc_compose {
415          my $f = shift or die "marc_compose needs field";          my $f = shift or die "marc_compose needs field";
416          die "marc_compose field must be numer" unless ($f =~ /^\d+$/);          die "marc_compose field must be numer" unless ($f =~ /^\d+$/);
417    
418          my ($i1,$i2) = defined($marc_indicators->{$f}) ? @{ $marc_indicators->{$f} } : (' ',' ');          my ($i1,$i2) = _get_marc_indicators( $f );
419          my $m = [ $f, $i1, $i2 ];          my $m = [ $f, $i1, $i2 ];
420    
421          warn "### marc_compose input subfields = ", dump(@_),$/ if ($debug > 2);          warn "### marc_compose input subfields = ", dump(@_),$/ if ($debug > 2);
# Line 562  sub marc_original_order { Line 566  sub marc_original_order {
566          my $r = $rec->{$from};          my $r = $rec->{$from};
567          die "record field $from isn't array ",dump( $rec ) unless (ref($r) eq 'ARRAY');          die "record field $from isn't array ",dump( $rec ) unless (ref($r) eq 'ARRAY');
568    
569          my ($i1,$i2) = defined($marc_indicators->{$to}) ? @{ $marc_indicators->{$to} } : (' ',' ');          my ($i1,$i2) = _get_marc_indicators( $to );
570          warn "## marc_original_order($to,$from) source = ", dump( $r ),$/ if ($debug > 1);          warn "## marc_original_order($to,$from) source = ", dump( $r ),$/ if ($debug > 1);
571    
572          foreach my $d (@$r) {          foreach my $d (@$r) {

Legend:
Removed from v.1046  
changed lines
  Added in v.1047

  ViewVC Help
Powered by ViewVC 1.1.26