sub addComma { my $number = reverse int shift; $number =~ s/(\d{3})(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $number; }
Partial credit goes to the Perl Cookbook, and the rest to int instead of a RE.
Dave
In reply to Re: Problem adding comma & removing decimal
by davido
in thread Problem adding comma & removing decimal
by Steny
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |