A question about Perl this time. Is following an OK solution (and backward compatible to e.g. 5.010) to write numeric values as they were parsed, be it either 3.14 or 3.14159, i.e. not to force rounding to arbitrarily "sane" length? Results of numeric calculations still have to be formatted. The emergency test for "e" is for values from whatever sources whose past allows Perl to treat them as strings. Scientific notation is syntax error. CAM::PDF does just "$val", I don't think it's good enough.
do {
use B;
if ( not B::SVf_POK & B::svref_2object( \$val )->FLAGS or
-1 != index $val, 'e' ) {
$val = sprintf '%.4f', $val;
$val =~ s/\.?0+$//
}
"$val"
}