passing parameters to function as variable

[email protected] ("Merritt H Lennox")
Newsgroups perl.perl4lib
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.