It looks like it was a Perl build configuration issue. The Perl build supports a `d_longdbl` option, which indicates whether long doubles are allowed or not. You can test whether it is set on your machine with:
perl -V:d_longdbl
More info at perldoc sprintf.
Thanks for your input everybody.
Edit:
Nope, that wasn't it either. Close inspection of the sprintf documentation revealed that the modifiers for a long double are q, ll, and L, NOT l. l is a valid modifer for integer types. D'oh.
It looks like most installations of perl will silently ignore the l, and parse the rest of the modifier correctly. Except on our user's site. ☹ Anyway, the problem was fixed by using a valid modifier for a long double.
FYI, I played with the same format specifiers in the C printf.
printf("The number is %lG\n", 0.001);
printf("The number is %LG\n", 0.001);
The first call “worked”, printing out 0.001, but the second call printed out a garbage value until I properly specified the type of the numeric literal:
printf("The number is %LG\n", 0.001L);
Apparently the C printf is silently ignoring the improper l modifier. This makes me suspect that most Perl installations ignore it too.