See "How can I output my numbers with commas added?" in perlfaq5.
In reply to Re: formatting numbers by ambrus in thread formatting numbers by Anonymous Monk