in reply to Formatting a number

perl -e '$num=12345678;$num=~s/(\d{1,3})$//,$num2=(($num)?",":"").$1.$num2 while$num;print$num2'