4 use MARC::File::USMARC;
6 my $file = MARC::File::USMARC->in( $ARGV[0] );
7 while ( my $marc = $file->next() ) {
8 my @cns = $marc->field('001'); # grabs all of them
9 my $cn = $marc->field('001')->data(); # grabs the first
10 $marc->delete_fields(@cns); # deletes all of them
11 my @sources = $marc->field('003'); # etc
12 my $source = $marc->field('003')->data();
13 $marc->delete_fields(@sources);
14 my @tags035 = $marc->field('035');
15 my $tag035 = $marc->field('035');
16 my $tag035a = defined $tag035 ? $tag035->subfield('a') : undef;
17 $marc->delete_fields(@tags035);
23 if (defined $source) {
24 push @arr, "($source) $cn";
28 if (defined $tag035a) {
32 my $new035 = MARC::Field->new(@arr);
33 $marc->insert_fields_ordered($new035);
35 print $marc->as_usmarc();