develooper Front page | perl.perl4lib | Postings from March 2012

Turning MARC record object back into a string

Thread Next
From:
Anne Highsmith
Date:
March 12, 2012 08:04
Subject:
Turning MARC record object back into a string
Message ID:
775B10AA8A27844087BFF7F4A62A713C1B9F8640@EXCH-MAILBOX3.library.tamu.edu
I am running a perl program that uses an API to update MARC records in an ILS. Voyager & BatchCat, for you Voyager folks. I have to pass a bunch of parameters to the API, of course, including the updated marc record as a string. The input record is UTF8, so the output must be also. Previously, I've used this statement to turn the MARC record object back into a string:

my $new_marc = sprintf($bib_rec->as_usmarc());

I'm running into lots of problems with the latest batch of records I'm editing, however, because the data has lots of embedded percent signs (%), which perl is not interpreting as part of the data but as part of a perl command; it fails with some kind of error in sprintf.

I tried using this statement instead of the above: my $new_marc = $bib_rec->as_usmarc();

i.e. leaving sprintf out of it entirely. It seems to work WITHOUT the errors induced by the percent signs. 

Can anybody think of any reason why I shouldn't just use " my $new_marc = $bib_rec->as_usmarc();". And if you can, can you suggest an alternative way to correctly turn the object into a string?



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About