displaying a specific number format in perl?

One way is with a disgusting regex:

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

A more elegant way is to use the Number::Format module. That will give you the format_number() function, which will, by default add commas every 3 digits
 
Back
Top