|
Lines 77-83
Returns an ISO-2709 scalar
Link Here
|
| 77 |
|
77 |
|
| 78 |
sub marc2marc { |
78 |
sub marc2marc { |
| 79 |
my ($marc,$to_flavour,$from_flavour,$encoding) = @_; |
79 |
my ($marc,$to_flavour,$from_flavour,$encoding) = @_; |
| 80 |
my $error = "Feature not yet implemented\n"; |
80 |
my $error; |
|
|
81 |
if ($to_flavour =~ m/marcstd/) { |
| 82 |
my $marc_record_obj; |
| 83 |
if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object |
| 84 |
$marc_record_obj = $marc; |
| 85 |
} else { # it's not a MARC::Record object, make it one |
| 86 |
eval { $marc_record_obj = MARC::Record->new_from_usmarc($marc) }; # handle exceptions |
| 87 |
|
| 88 |
# conversion to MARC::Record object failed, populate $error |
| 89 |
if ($@) { $error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR }; |
| 90 |
} |
| 91 |
unless ($error) { |
| 92 |
my @privatefields; |
| 93 |
foreach my $field ($marc_record_obj->fields()) { |
| 94 |
if ($field->tag() =~ m/9/ && ($field->tag() != '490' || C4::Context->preference("marcflavour") eq 'UNIMARC')) { |
| 95 |
push @privatefields, $field; |
| 96 |
} elsif (! ($field->is_control_field())) { |
| 97 |
$field->delete_subfield(code => '9') if ($field->subfield('9')); |
| 98 |
} |
| 99 |
} |
| 100 |
$marc_record_obj->delete_field(@privatefields); |
| 101 |
$marc = $marc_record_obj->as_usmarc(); |
| 102 |
} |
| 103 |
} else { |
| 104 |
$error = "Feature not yet implemented\n"; |
| 105 |
} |
| 81 |
return ($error,$marc); |
106 |
return ($error,$marc); |
| 82 |
} |
107 |
} |
| 83 |
|
108 |
|