Using MARC::Record to delete fields
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
RE: Using MARC::Record to delete fields
On Monday, July 16, 2007 8:41 AM, Michael Bowden wrote: Our MARC records have several 035 fields. I want to delete all of the 035s except for the 1st one. I've modified your code below, removing the foreach field loop. The modified code remains unfinished, as I'll leave it to you to determine the best way to remove $first035 from @m035. while (my $record = $batch-next()) { #get first 035 to retain my $first035 = $record-field('035'); #get all 035s my @m035 = $record-field('035'); ### ###remove 1st 035 from @m035 array using array manipulation techniques ### #remove remaining 035s $record-delete_field(@m035); print $record-as_formatted(),\n\n; } I hope this helps, Bryan Baldus [EMAIL PROTECTED] [EMAIL PROTECTED] http://home.inwave.com/eija