2.16.2. Solution
Reverse the string so you can use backtracking to avoid substitution
in the fractional part of the number. Then use a regular expression
to find where you need commas, and substitute them in. Finally,
reverse the string back.
sub commify {
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}