www.fromthevalley.com.au

Break up an integer with a ,

   This is how you break up an integer to add , in the currency.

 

Ie if bid_total was 1000000, the output would be 1,000,000.

 

   $bid_total = reverse $bid_total;
   $bid_total =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
   $bid_total = scalar reverse $bid_total;

 

Also can be used as a sub routine:

 

sub commify {
my $text = reverse $_[0];
$text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
return scalar reverse $text;
}

 

HOMEAJAXAPACHEBizphoneCSSDNSGeneralGraphicsHTMLHardwareJavascriptLinuxMACMS SQLMailMicrosoftOFFICE 365PerlPostgresSEOSocial MediaVMwareWindows 10