Roy- THANK YOU! I was going crazy.
~Jenn From: roy.zim...@wmich.edu [mailto:roy.zim...@wmich.edu] Sent: Thursday, May 12, 2011 2:33 PM To: perl4lib@perl.org; Nolte, Jennifer Subject: Re: Add 006 and 007 tags to records? Jenn, that's a misapplication of the fieldaddtobeg function. Here's the definition for that function: fieldaddtobeg | field | data field 3 digits specify the field data new field data added to the beginning of the field (only for fields without indicators (001-009) It adds data to the beginning of those sub-010 fields. It does not add a new field. To add a field, use the ADD stanza; from the documentation: [ADD] field | L1 | L2 | # | subfield | data field 3 digits specify which field to add L1 the first indicator character; space if empty L2 the second indicator character; space if empty # the number of subfield+data pairings following subfield 1 character denoting the subfield data the subfield data In each case, the field, with specified indicators, if any, subfield, and data is added as a complete field, whether or not such a field already exists. If you're adding a fixed field, leave L1, L2, "#", and subfield blank, empty, i.e., not even a space; to wit: 009|||||this is 009 stuff I hope this helps. Roy On 5/12/2011 12:48 PM, Bryan Baldus wrote: 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<mailto:bryan.bal...@quality-books.com> eij...@cpan.org<mailto:eij...@cpan.org> http://home.comcast.net/~eijabb/