On Thursday, May 12, 2011 10:58 AM, Jenn Nolte wrote: >I am working on a shell script that will process the MARC records that >represent items from our e-serials management database, and the thing I am >stuck on is adding brand new 006 and 007 fixed field tags to each record. I am >using the marcedit.pl fieldaddtobeg function, but it corrupts the records and >makes them unparseable. >Is there a quick and easy way to do this within a script? (I know Perl works >best with MARC but I am open to any suggestions).
I'm not familiar with marcedit.pl. I'd use MARC::Batch and its related modules, similar to the mock-up listed below (which assumes the 008 to be present to insert the new field(s) in the proper order; I've thrown the code together haphazardly, so it may contain errors). Of course with 006 and 007, you also run into length issues--006 is always 18 bytes; 007's length depends on the category of material. If the fields don't have the correct length, some systems may reject the records. ############## use MARC::Batch; #$inputfile = "path_to_your_file_however_you_get_it"; my $batch = MARC::Batch->new('USMARC', "$inputfile"); #$exportfile = "path_to_your_file_however_you_get_it"; open(OUT, ">$exportfile") or die "Can not open $exportfile, $!"; RECORD: while (my $record = $batch->next()) { # $field006 = ''; #string of valid 006 characters (change 006 to 007 for 007) my $new006 = MARC::Field->new( '006', $field006); $record->insert_fields_before($record->field('008'), ($new006)); print OUT $record->as_usmarc(); }# while records ################# I hope this helps, Bryan Baldus Cataloger Quality Books Inc. The Best of America's Independent Presses 1-800-323-4241x402 bryan.bal...@quality-books.com eij...@cpan.org http://home.comcast.net/~eijabb/