[ILUG] sprintf formatting question
Phil
philb at vodafone.ie
Thu Aug 21 12:04:10 IST 2008
Pádraig Brady wrote:
>>> my $foo = 5188931580; # > 4294967295
>>> print sprintf("%10u\n", $foo);
>>>
>>> (actually prints out 4294967295)
>> I know nothing about perl, and don't intent to change that,
>> though I did have a similar issue with python:
>> http://bugs.python.org/issue1742669
>>
>> That suggests that %10s or %10.f might work for you instead.
>
> So did these work for you?
Hi Pádraig,
I just checked this now and both seem to work fine. I added in 0 padding
to 12 spaces just to verify that it would behave and it did:)
my $foo = 5188931580; # > 4294967295
print sprintf("-->%012s<--\n", $foo);
print sprintf("-->%012.f<--\n", $foo);
Thanks for your help,
-Phil
More information about the ILUG
mailing list