I just published the new groff preprocessor `gperl'. It allows to add Perl code to groff files.
That makes available easy mathematical calculations, the famous Perl regular expressions, and much more. The result can be stored in a roff string or register variable. This result is obtained from the standard output, e.g. by the Perl command `print'. The Perl part is identified by the new .Perl request. Good luck Bernd Warken