X-Git-Url: http://git.equinoxoli.org/?p=migration-tools.git;a=blobdiff_plain;f=extract_holdings;h=fadcf8dfe47cacc854cb7851ecdf43a6e0d6d9cd;hp=78fbde5c8a93ec13f27551da5e082523db9819d2;hb=3bd5dd6ddf3857cf8c54cfe10df9fef27e2478d0;hpb=e62ff5b8e90d327bc36e4f347ed92a919cdcd539 diff --git a/extract_holdings b/extract_holdings index 78fbde5..fadcf8d 100755 --- a/extract_holdings +++ b/extract_holdings @@ -49,10 +49,13 @@ sub extract_holdings { while ( $m->{data}{recs}[$i] ) { print HOLDINGS "BEGIN;\n\negid\thseq\t" unless $j; my $rec = $m->{data}{recs}[$i]; + my $k = 0; # holding-within-record pointer # for each holdings tag in the record... - for my $holdidx ( @{$rec->{tmap}{ $c->{holdings} }} ) { + while ( $rec->{tmap}{ $c->{holdings} }[$k] ) { + my $holdidx = $rec->{tmap}{ $c->{holdings} }[$k]; my $tagid = $rec->{tags}[$holdidx]{tag}; + $k++; my @out = (); # clear the output buffer push @out, $rec->{egid}; # slug in the egid first thing @@ -79,8 +82,7 @@ sub extract_holdings { my $idx = $rec->{tmap}{$othertag}[0]; # get index into tags struct for my $sub ( sort keys %{$rec->{tags}[$idx]{uni}} ) { push @out, $rec->{tags}[$idx]{uni}{$sub}; - print "l_", $m->name($rec->{tags}[$idx]{tag}, $sub), "\t" - unless $j; + print "l_", $m->name($rec->{tags}[$idx]{tag}, $sub), "\t" unless $j; } } @@ -89,6 +91,8 @@ sub extract_holdings { print HOLDINGS join("\t", @out); print HOLDINGS "\n"; $j++; + + @out = undef; } $i++; print "\r$i";