"How can I output my numbers with commas added?" question in perlfaq5
[email protected] (Ævar Arnfjörð Bjarmason) Thu, 21 Apr 2005 04:09:53 +0000
| Newsgroups | perl.perlfaq.workers |
|---|---|
| Message-ID | <[email protected]> |
Regarding the "How can I output my numbers with commas added?"
question in perlfaq5; here's an even simpler way to achive the same:
sub commify {
local $_ = reverse shift;
s/(\d{3})(?=\d)(?!\d*\.)/$1,/g;
scalar reverse;
}