On Fri, Feb 11, 2005 at 08:57:36AM -0600, Bruffey, Mark wrote: > I'm really new to perl scripting but I believe that I could accomplish > my task if I had a little help or an example. I need a simple script > that will copy existing data from field 852 $6 to field 949 $a. It this > possible with MARC::Record?
Sure, try this out: use strict; use warnings; use MARC::Batch; ## open MARC batch file my $in = shift; my $batch = MARC::Batch->new( 'USMARC', $in ); ## open a new output file open( OUT, ">$in.new" ); ## iterate through records in the batch while ( my $record = $batch->next() ) { ## look for 852 $6 my $f852 = $record->field('852'); ## if there is an 852 $6 then add the 949 $a if ( $f852 and $f852->subfield('6') ) { $record->append_fields( MARC::Field->new( '949', '', '', a => $f852->subfield('6') ) ); print OUT $record->as_usmarc(); } } This will only output the modified records. If you haven't seen it yet there are some recipes in the MARC::Record tutorial which you can find here: http://search.cpan.org/perldoc?MARC::Doc::Tutorial By all means this list is for questions about using Perl in libraries so your questions are welcome :) //Ed