#!/usr/bin/perl -w
use MARC::Record;
use MARC::Batch;
my $batch = MARC::Batch->new('USMARC','/home/laxendion/tools/iso/marc');
open(OUT,'> new1.dat') or die $!;
$batch->strict_off();
## read in each record.
while ( my $record = $batch->next() ) {
##fetch 852h
#my $good = $record->field('681');
#my $goodsub = $good->subfield('a');
#$record->subfield(681,"a");
## find the tag after 900.
my $class = $record->field('681')->subfield("a");
my $before;
foreach ($record->fields()) {
$before = $_;
last if $_->tag() > 800;
}
## create the 942 field.
my $new = MARC::Field->new('805','','','d' => $class);
## insert our 942 field after the $before.
$record->insert_fields_before($before,$new);
print $class . "\n";
## and print out the new record.
print OUT $record->as_usmarc();
}
沒有留言:
張貼留言