in reply to "Commifying" a number
- I'm interested to know if there's a "simpler" way to do this - ideally getting rid of the super-hideous while loop
How about a recursive solution?
...no super-hideous while loop there, and no regex compilation either. ;-)sub commify { my($num) = @_; return $num if length($num)<4; return commify(substr($num,0,-3), $len).",".substr($num,-3,3); }
The only downside is that this only works for integers.
--
hiseldl
What time is it? It's Camel Time!
In Section
Seekers of Perl Wisdom