Think about Loose Coupling | |
PerlMonks |
Re: "Commifying" a numberby jreades (Friar) |
on Dec 12, 2002 at 13:04 UTC ( [id://219312]=note: print w/replies, xml ) | Need Help?? |
The closest that I can come, and I don't know if this fits the bill of being simpler, is this:
This prints out:
Of course, this lends itself to a one-liner, and although I'm not sure if you can quite get there you can certainly reduce the number of lines. Also note that it falls flat on its face if you try to use a decimal or floating-point number. Maybe printf/sprintf can do what you want more simply than this? Update -- I got the right result by doing the following:
Readable? No. Usable? Barely. No while loop? Check.
In Section
Seekers of Perl Wisdom
|
|