http://qs321.pair.com?node_id=156688


in reply to Re: Re: Answer: How do I add commas to a number?
in thread numbers

Then simply extend the search/replace pattern. Since this is just cosmetics, it is not detrimental if it fails. Here is a complete example. Run this code and it will become clear what is going on:
$c1=$c2=$c3=111222333444555; $c1=~ s/^(-?\d+)(\d{3})(\d{3})/$1,$2,$3/; $c2=~ s/^(-?\d+)(\d{3})(\d{3})(\d{3})/$1,$2,$3,$4/; $c3=~ s/^(-?\d+)(\d{3})(\d{3})(\d{3})(\d{3})/$1,$2,$3,$4,$5/; print<<END; $c1 $c2 $c3 END