On Feb 11, 2005, at 12:04 PM, Jim Van Fleet wrote:

> sub commify {
>     my $text = reverse $_[0];
>     $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
>     return scalar reverse $text;
> }

Here's a direct Ruby translation:

def commify( number )
	text = number.to_s.reverse
	text.gsub!(/(\d\d\d)(?=\d)(?!\d*\.)/, '\1,')
	text.reverse
end

Hope that helps.

James Edward Gray II