RE: Using MARC::Record to delete fields

2007-07-16 Thread Bryan Baldus
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
 



Re: Using MARC::Record to delete fields

2007-07-16 Thread Ed Summers

I can see where Bryan was going with this--but unfortunately
delete_field() does not operate on a list of fields!! I just checked
in delete_fields() and a test for it...but that's not going to help
Michael right now. Here's how I'd delete all but the first 035:

   # get a list of all 035 fields in the record
   my @m035s = $record->field('035');

   # remove the first 035 from the list
   shift(@m035s);

   # delete any that remain in the list
   foreach $field (@m035s) {
   $record->delete_field($field);
   }

This will work with records where there are zero or one 035s as well.
Does it make sense?

//Ed