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

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

revision 541 by dpavlin, Thu Jun 29 21:18:50 2006 UTC revision 542 by dpavlin, Thu Jun 29 21:18:59 2006 UTC
# Line 152  Get all fields defined by calls to C<mar Line 152  Get all fields defined by calls to C<mar
152    
153          $marc->add_fields( WebPAC::Normalize:_get_marc21_fields() );          $marc->add_fields( WebPAC::Normalize:_get_marc21_fields() );
154    
155    B<TODO>: implement exceptions to magic which unrolls repeated subfields
156    as new field with that subfield.
157    
158  =cut  =cut
159    
160  sub _get_marc21_fields {  sub _get_marc21_fields {
161          return @{$marc21};          my @m;
162            my $last;
163            foreach my $row (@{ $marc21 }) {
164                    if ($last && (
165                            $last->[0] eq $row->[0] ||              # check if field is same
166                            $last->[1] eq $row->[1] ||              # check for i1
167                            $last->[2] eq $row->[2]                 # and for i2
168                    ) ) {
169                            $last->[3]->{ $row->[3] } = $row->[4];
170                            warn "## ++ added $row->[0] ^$row->[3]\n";
171                            next;
172                    } elsif ($last) {
173                            push @m, $last;
174                    }
175    
176                    push @m, $row;
177            }
178    
179            push @m, $last if ($last);
180    
181            return @m;
182  }  }
183    
184  =head1 Functions to create C<data_structure>  =head1 Functions to create C<data_structure>

Legend:
Removed from v.541  
changed lines
  Added in v.542

  ViewVC Help
Powered by ViewVC 1.1.26