Sébastien Aperghis-Tramoni writes: > I would like to expose an idea I had to try solving (at least partly) > the problem of serializing scalar values from Perl. I recently had this same itch, and I contributed some very simple code to the MongoDB project that solves it in a different way: https://github.com/mongodb/mongo-perl-driver/pull/63 IMO, it's not helpful to use the *original* data type, because it prevents me from casting to the type I actually want. It's much more useful to provide an explicit casting mechanism and then use the resultant type. Dave Mitchell <davem <at> iabyn.com> writes: > > * the serialiser documentation could state that for things to be saved > as floats, you must do *= 1.0 shortly before saving; That doesn't actually work: % perl -MDevel::Peek -E '$x=1; print Dump $x; $x *= 1.0; $x += 0.0; print Dump $x' SV = IV(0x1fbe7458) at 0x1fbe7468 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 1 SV = IV(0x1fbe7458) at 0x1fbe7468 REFCNT = 1 FLAGS = (IOK,pIOK) IV = 1 That was in fact the motivating case behind creating the explicit cast functions. -KenThread Previous | Thread Next