Merritt, I guess you can do it with eval, but you can also do it with an array instead of a string.
my @a245 = ('a', 'The Title', 'b', 'Subtitle', 'c', 'Author', 'h', '[Electronic resource]', ); my $field = $record->field('245'); my $revised_245 = MARC::Field->new('245', '', '', @a245); $field->replace_with($revised_245); Leif Andersson -----Ursprungligt meddelande----- Från: Merritt H Lennox [mailto:[EMAIL PROTECTED] Skickat: den 16 augusti 2007 20:35 Till: perl4lib@perl.org Ämne: passing parameters to function as variable Hi - I was wondering if anyone has tried creating a variable containing the parameter list for a MARC method. In the snippet below, I'm doing some cleanup on subfields of the 245, and inserting a default subfield h for those lacking one. I never know which subfields I'll have, so rather than using a cumbersome series of if...elsif...else statements, I'd construct the string I want to pass to the new() function, and insert it once. If any subfield doesn't exist, the SFstring variable for that subfield is empty. I know that the string in $subfield_list_245 contains the string I want, from having used the print statement [1], but every run gives me the error " Field 245 must have at least one subfield". I've tried using the eval statement on the $subfield_list_245, and using various quotation marks around it, but new() just doesn't recognize or want to work with the string. Is there a way to make this approach work? Are the blanks I've concatenated to the end a problem? Or is there a more succinct way of approaching this in the first place? Start snippet>>>> if ( ! $subfield_245h ) { my $subfield_list_245 = $a_SFstring . $b_SFstring . $c_SFstring . ',h=>' . "'" . "[Electronic resource]" . "'" . $n_SFstring . $ p_SFstring; ## print $subfield_list_245; my $revised_245 = MARC::Field->new('245', '', '',$subfield_list_245); $record->replace_with($revised_245); } <<<<end snippet Thanks for any ideas! Merritt [1] for my simple test record, the subfield list prints out: a=>'Accountancy Ireland',h=>'[Electronic resource]' Merritt Lennox Library Management System Administrator 550A Bird Library Syracuse University Syracuse, NY 13244 315-443-9629 [EMAIL PROTECTED] "Never doubt that a small group of thoughtful, committed citizens can change the world. Indeed, it's the only thing that ever has." - Margaret Mead