http://qs321.pair.com?node_id=219370


in reply to "Commifying" a number

How about a recursive solution?

sub commify { my($num) = @_; return $num if length($num)<4; return commify(substr($num,0,-3), $len).",".substr($num,-3,3); }
...no super-hideous while loop there, and no regex compilation either. ;-)

The only downside is that this only works for integers.

--
hiseldl
What time is it? It's Camel Time!