perlfaq5: How can I output my numbers with commas added?

[email protected] (pizza)
Newsgroups perl.perlfaq.workers
Message-ID <[email protected]>
this is the shortest regex i can come up with that seems to work all in one 
line.

s/([+-])?(\d{1,3})(?=(\d{3})+)/$1$2,/g;

------------------------------
#!/usr/bin/perl -l
$_ = "-10,000000";
s/([+-])?(\d{1,3})(?=(\d{3})+)/$1$2,/g;
print;
------------------------------

it seems to handle a leading +/- and existing commas

feedback appreciated.

pizza
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.