in reply to Separating big numbers with commas
The Perl Cookbook (Recipe 2.17) has just what you need:
my $number = 987654321; print commify($number); sub commify { my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text }
Update: blakem is right. And besides, my answer is incomplete. For a more complete answer, look here.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Separating big numbers with commas
by Anonymous Monk on Aug 07, 2003 at 19:56 UTC |