[librecat-dev] string operations, defining functions in Catmandu

Uldis Bojars captsolo at gmail.com
Wed Jun 28 18:41:44 CEST 2017


Hi,

Could you suggest how to do this in Catmandu:

I need to form a new MARC field ("400") that consist of some subfields (in
this order: $a $q $b $c $d) of an existing field ("100"). That much is not
difficult, but there's another condition:

"." must be added to the last subfield that exists (e.g. if $d exists
append "." to it unless it already ends with ".", otherwise do the same
with $c, [...]) .

Questions:

1) how to determine if a field (e.g. fld_100d created via marc_map) ends
with "." ?

2) is there a way to "package" some functionality and call it when needed?

In this case it would be good to create a function that appends "." to the
field provided as a parameter unless it already ends with ".".

Then what is needed could be achieved like this:

if exists("fld_100d"):
   my_function("fld_100d")
elsif exists("fld_100c"):
   my_function("fld_100c")
elsif [...]
   [...]
end

P.S. Perhaps there is a more idiomatic way how to do this in Catmandu?

Thanks,
Uldis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20170628/11c5b8cc/attachment.html>


More information about the librecat-dev mailing list