Using MARC::Record to delete fields

[email protected] ("Michael Bowden")
Newsgroups perl.perl4lib
Message-ID <[email protected]>
Hi:
 
I have used MARC::Record for several years now.  I finally have hit a snag in processing MARC records.  Our MARC records have several 035 fields.  I want to delete all of the 035s except for the 1st one.  I have tried several things to accomplish this task without any luck.  I have tried to delete all the 035s and then add back the one 035 that I want to keep.  I have discovered that $record->delete_field(@m035) deletes all the 035s EXCEPT for the last one.  Here is my code:
 
while (my $record = $batch->next()) {
   my @m035 = $record->field('035');
   
   foreach ( $record->fields() ) {
      if (@m035) {
         $record->delete_field(@m035);
         }
      print $record->as_formatted(),"\n\n";
   }
 
Am I doing something wrong in trying to delete all the 035s?
 
All suggestions are greatly appreciated!
 
Michael
 
Michael L. Bowden
Harrisburg Area Community College
[email protected]
 

 

Harrisburg Area Community College
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.