in reply to How do I print a large integer with thousands separators?
$num = 123456789; $num = reverse $num; # reverse the number's digits $num =~ s/(\d{3})/$1,/g; # insert comma every 3 digits, from beginning $num = reverse $num; # Reverse the result $num =~ s/^\,//; # remove leading comma, if any
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Answer: How do I print a large integer with thousands separators?
by stevecomrie (Beadle) on Oct 27, 2004 at 12:18 UTC |