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

Re: Turning MARC record object back into a string

Thread Previous | Thread Next
From:
Colin Campbell
Date:
March 14, 2012 02:06
Subject:
Re: Turning MARC record object back into a string
Message ID:
20120312162359.GA25701@zazou.cscnet.co.uk
On Mon, Mar 12, 2012 at 01:49:36PM +0000, Anne Highsmith wrote:
> 
> 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?
> 
No thats the way the interface should work.
I think your use of sprintf
is mistaken. sprintf takes a format string and a list of variables and
formats the variables according to the format string. Use of sprintf and
printf is often a danger sign if they turn up in perl code.
What your code was doing was using the string returned by the ->as_usmarc
method and using that to format an empty list of variables, as soon as
'%' cropped up in a record the fact that the list was empty became a
problem. 

Your only potential problems with the marc string are if you want to
pass it to some interface that will get upset at MARC's embedded control
characters or the character set used in the record. But I suspect thats
not a problem because sprintf would not have changed that.

Colin

-- 
Colin Campbell
Chief Software Engineer,
PTFS Europe Limited
Content Management and Library Solutions
+44 (0) 800 756 6803 (phone)
+44 (0) 7759 633626  (mobile)
colin.campbell@ptfs-europe.com
skype: colin_campbell2

http://www.ptfs-europe.com

Thread Previous | 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