in reply to How do I print a large integer with thousands separators?
for ( $number ) { /\./ ? s/(?<=\d)(?=(\d{3})+(?:\.))/,/g : s/(?<=\d)(?=(\d{3})+(?!\d))/,/g; }
This says if the number has a decimal point, end there for the purposes of commafication. Otherwise, go to the end of the string.
|
|---|