$number=1234567; # with commas, should be "1,234,567"
$number =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g;
####
$number='1234567890.01';
$number =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g;
##
##
$number='1234567890.0123456789'; # with commas, should be "1,234,567,890.01
$number =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g;
##
##
$number='1234567890'; # with commas, should be "1,234,567,890.01
$number .= '.' if ($number !~ /\./); # Make sure we end with a decimal if we don't have a decimal
$number =~ s/(\d)(?=(\d{3},?)+(\.))/$1\,/g;
chop $number if ($number =~ /\.$/); # Get rid of that useless trailing decimal
print "N $number \n";
$number='1234567890.01234567687'; # with commas, should be "1,234,567,890.01
$number .= '.' if ($number !~ /\./);# Make sure we end with a decimal if we don't have a decimal
$number =~ s/(\d)(?=(\d{3},?)+(\.))/$1\,/g;
chop $number if ($number =~ /\.$/); # Get rid of that useless trailing decimal
print "N $number \n";