How to add commas to a number?
- From: gjwpp88@xxxxxxxxx (JerryP)
- Date: Wed, 28 Nov 2007 08:27:19 -0800 (PST)
Hi!
I am trying to get this to work, but I am not having any luck?
use strict;
use warnings;
sub commify {
local($_) = shift;
1 while s/^(-?\d+)(\d{3})/$1,$2/;
return $_;
}
If I input these numbers:
6238.12
121150.98
104903.30
113569.26
40239.51
8733.55
I get :
6238.12
121150.98
104903.30
113569.26
40,239.51
8,733.55
Any ideas?
Thanks
Jerry
.
- Follow-Ups:
- Re: How to add commas to a number?
- From: Gunnar Hjalmarsson
- RE: How to add commas to a number?
- From: John Moon
- Re: How to add commas to a number?
- Prev by Date: Re: fixed list combinatorics
- Next by Date: Re: fixed list combinatorics
- Previous by thread: Comparing Regular Expression in Perl vs Python
- Next by thread: RE: How to add commas to a number?
- Index(es):
Relevant Pages
|