![]() |
|
We don't bite newbies here... much | |
PerlMonks |
Re: How do I print a large integer with thousands separators?by Anonymous Monk |
on Jan 31, 2004 at 05:11 UTC ( #325505=note: print w/replies, xml ) | Need Help?? |
I benchmarked the following methods 'while loop' is the "1 while..." method. 'reverse' is the Andrew Johnson method. 'lookahead' is the stefp method. 'manual' is the one using substr. 'le3manual' is the one using substr with an initial check to make sure there are more than three digits.
Nk/s = N thousands of completed commafications per second Basically it looks like the substr method, with the <=3 clause, obliterates the competition. I feel dirty saying it, but looks like a one-liner regexp is not the best solution. (My test script is available here)
In Section
Seekers of Perl Wisdom
|
|