Your skill will accomplish
what the force of many cannot
pack() returns an unusable stringby syphilis (Bishop)
|on May 26, 2021 at 13:39 UTC||Need Help??|
syphilis has asked for the wisdom of the Perl Monks concerning the following question:
This post arises from an XY problem (for which I already have a very serviceable, albeit inferior, PQ solution).
The following demo script works fine when I set $template to 'd' or 'd<' or 'd>':
You can run that on any recent perl, and, for that given template, it should correctly output 3333333333330340.
The problem arises when I change the template to 'D' or 'D<' or 'D>'.
Of course, with the capitalized "D" templates, we're dealing with long doubles. And if you're running perl-5.32.x or earlier, these "D" templates are disallowed unless perl's nvtype is "long double".
However, if you're running perl-5.34.0, then the "D" templates are allowed irrespective of nvtype, thanks to the wonders of modern insanity.
(It's quite sane that the "D" templates now work on -Dusequadmath builds ... but I'm still aghast that they now also work on perls where nvtype is double.)
So ... if you have one of those permitted perl configurations, and you change the template to one of the 3 permitted "D" forms, you'll see the script fail, with the diagnostic warning:
I wonder why that happens ? Is it because of the embedded NULLs in $p ?
More importantly, how do I get to pass that string $p to the system command so that when the template is set to 'D<' the script successfully outputs the expected (and correct) 9a999999999999990040000000000000 (or 00999999999999990040000000000000 if perl is 5.34.0 && nvtype is double).
I'm hitting the same issue on both Windows 7 and Ubuntu-20.04.