Here's a little Perl snippet which will place commas in any number string right where they belong:
my $text = reverse $_;
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
So for example, by calling
will be returned.
All the little commas right exactly at the correct positions using a simple regular expression. Pretty amazing language that Perl is. Does it make sense?
~ Posted at
| Computers and stuff