[librecat-dev] Doing math calculations inside a Catmandu fix

Siebert, Dr. Martina Martina.Siebert at sbb.spk-berlin.de
Fri Oct 27 15:16:46 CEST 2023


Dear Patrick,

great! Thanks!!

I needed to change the call-up of the Perl script to
perlcode(./myscript.pl)
Nicely the error message told me what needed to change.

Best,
Martina



Von: Patrick Hochstenbach <Patrick.Hochstenbach at UGent.be>
Gesendet: Freitag, 27. Oktober 2023 14:49
An: Siebert, Dr. Martina <Martina.Siebert at sbb.spk-berlin.de>; librecat-dev at lists.uni-bielefeld.de
Betreff: Re: Doing math calculations inside a Catmandu fix

Dear Martina,

Perl fixes have a very limited support for calculations. But with the perlcode fix you can do any kind of calculation possible in Perl (and that is a lot).

E.g. here is a way  to add 1 to the year field in the MARC 008/07-10 tag:


# copy 008 date to the 'date' field


marc_map(008/07-10,date)

# do some calculation

perlcode(myscript.pl)

# return the 'date' value back into the date field

marc_set(008/07-10,$.date)


where myscript.pl is a file that contains:



sub {

    my $data = shift;



    $data->{date} = $data->{date} + 1;



    return $data;

}


BR
Patrick
________________________________
From: librecat-dev-bounces at lists.uni-bielefeld.de<mailto:librecat-dev-bounces at lists.uni-bielefeld.de> <librecat-dev-bounces at lists.uni-bielefeld.de<mailto:librecat-dev-bounces at lists.uni-bielefeld.de>> on behalf of Siebert, Dr. Martina <Martina.Siebert at sbb.spk-berlin.de<mailto:Martina.Siebert at sbb.spk-berlin.de>>
Sent: 27 October 2023 14:25
To: librecat-dev at lists.uni-bielefeld.de<mailto:librecat-dev at lists.uni-bielefeld.de> <librecat-dev at lists.uni-bielefeld.de<mailto:librecat-dev at lists.uni-bielefeld.de>>
Subject: [librecat-dev] Doing math calculations inside a Catmandu fix


Dear all,



I am stuck with this problem:

I only have a date in Taiwan Republican counting in my data and need a Georgian date for PICA+.

How do I add 1911 to the value 112 to get 2023?



Best,

Martina



______________________________________________

Dr. Martina Siebert

Ostasienabteilung | CrossAsia

Staatsbibliothek zu Berlin - Preußischer Kulturbesitz



martina.siebert at sbb.spk-berlin.de<mailto:martina.siebert at sbb.spk-berlin.de>

www.staatsbibliothek-berlin.de<http://www.staatsbibliothek-berlin.de/>



Im Rahmen der E-Mail-Kommunikation werden gegebenenfalls personenbezogene Daten verarbeitet.
Unsere Hinweise zum Datenschutz finden Sie hier: http://sbb.berlin/datenschutz


-------------- n?chster Teil --------------
Ein Dateianhang mit HTML-Daten wurde abgetrennt...
URL: <http://lists.uni-bielefeld.de/mailman2/unibi/public/librecat-dev/attachments/20231027/e2fffb5a/attachment.html>


More information about the librecat-dev mailing list