Reggie Wrote:
> 
> I am trying to print a number with commas in it. I cannot 
> find the correct syntax to do this with printf.
> I considered using the substr function but this depends on 
> mealways knowing the size of the number.
> Can you help me with this?

I like to use the method listed in the perldocs.  Try this:

  perldoc -q "output my numbers with commas"

It lists a really cool solution, although I'm sure there are plenty of others :)
It credits Benjamin Goldberg with this:

   s/(^[-+]?\d+?(?=(?>(?:\d{3})+)(?!\d))|\G\d{3}(?=\d))/$1,/g;

Hope this will work for you,

Jared

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to