Lines 1473-1497
sub merge {
Link Here
|
1473 |
my $newtag = $tags_new && @$tags_new |
1473 |
my $newtag = $tags_new && @$tags_new |
1474 |
? _merge_newtag( $tag, $tags_new ) |
1474 |
? _merge_newtag( $tag, $tags_new ) |
1475 |
: $tag; |
1475 |
: $tag; |
1476 |
my $field_to = MARC::Field->new( |
1476 |
my (@prefix, @postfix); |
1477 |
$newtag, |
|
|
1478 |
$field->indicator(1), |
1479 |
$field->indicator(2), |
1480 |
"9" => $mergeto, |
1481 |
); |
1482 |
foreach my $subfield ( grep { $_->[0] ne '9' } @record_to ) { |
1483 |
$field_to->add_subfields( $subfield->[0] => $subfield->[1] ); |
1484 |
} |
1485 |
if ( !$overwrite ) { |
1477 |
if ( !$overwrite ) { |
1486 |
# add subfields back in loose mode, check skip_subfields |
1478 |
# add subfields back in loose mode, check skip_subfields |
|
|
1479 |
# check the relative position resp. controlled subfields |
1480 |
my $prefix_flag = 1; |
1487 |
foreach my $subfield ( $field->subfields ) { |
1481 |
foreach my $subfield ( $field->subfields ) { |
1488 |
next if $skip_subfields->{ $subfield->[0] }; |
1482 |
if ( $skip_subfields->{ $subfield->[0] } ) { |
1489 |
$field_to->add_subfields( $subfield->[0], $subfield->[1] ); |
1483 |
$prefix_flag = 0; |
|
|
1484 |
next; |
1485 |
} |
1486 |
if ($prefix_flag) { |
1487 |
push @prefix, [ $subfield->[0], $subfield->[1] ] ; |
1488 |
} else { |
1489 |
push @postfix, [ $subfield->[0], $subfield->[1] ] ; |
1490 |
} |
1491 |
} |
1492 |
} |
1493 |
my $field_to; |
1494 |
foreach my $subfield ( grep { $_->[0] ne '9' } (@prefix, @record_to, @postfix) ) { |
1495 |
unless ($field_to) { |
1496 |
$field_to = MARC::Field->new( |
1497 |
$newtag, |
1498 |
$field->indicator(1), |
1499 |
$field->indicator(2), |
1500 |
$subfield->[0] => $subfield->[1], |
1501 |
); |
1502 |
} else { |
1503 |
$field_to->add_subfields( $subfield->[0] => $subfield->[1] ); |
1490 |
} |
1504 |
} |
1491 |
} |
1505 |
} |
|
|
1506 |
$field_to->add_subfields( 9 => $mergeto ); |
1507 |
|
1492 |
if ($tags_new && @$tags_new) { |
1508 |
if ($tags_new && @$tags_new) { |
1493 |
$marcrecord->delete_field($field); |
1509 |
$marcrecord->delete_field($field); |
1494 |
append_fields_ordered( $marcrecord, $field_to ); |
1510 |
$marcrecord->insert_fields_ordered($field_to); |
1495 |
} else { |
1511 |
} else { |
1496 |
$field->replace_with($field_to); |
1512 |
$field->replace_with($field_to); |
1497 |
} |
1513 |
} |
1498 |
- |
|
|