Help for this page

Select Code to Download


  1. or download this
    $number=1234567; # with commas, should be "1,234,567"
    $number =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g;
    
  2. or download this
    $number='1234567890.01';
    $number =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g;
    
  3. or download this
    $number='1234567890.0123456789'; # with commas, should be "1,234,567,8
    +90.01
    $number =~ s/(\d)(?=(\d{3})+(\D|$))/$1\,/g;
    
  4. or download this
    $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";