Here's a more generic solution that I used to commafy not only integers, but also decimals.
{
local $_ = $amount;
/\./ ? s/(?<=\d)(?=(\d{3})+(?:\.))/,/g
: s/(?<=\d)(?=(\d{3})+(?!\d))/,/g;
$amount = $_;
}
If you look under Q&A, you will find related topics on how to commafy a number. You should learn to use the Super Search feature of the Perl Monks site. A lot of the questions have been discussed in detail, you just have to search for them.