Thread: How to format Mb numbers?
Results 1 to 2 of 2
Related
-
How to round numbers Forum: CGI Perl Forum
Replies: 6
-
04-11-2005, 08:30 AM #1
How to format Mb numbers?
Hello,
If I have a number of 123456789, how do I reformat it to be shown as 123,456,789?
-
04-11-2005, 11:38 AM #2
Hi,
I'm not so hot on perl, but some googling found this sub, designed for formatting to currencies:
Code:sub CommaFormatted { my $delimiter = ','; # replace comma if desired my($n,$d) = split /\./,shift,2; my @a = (); while($n =~ /\d\d\d\d/) { $n =~ s/(\d\d\d)$//; unshift @a,$1; } unshift @a,$n; $n = join $delimiter,@a; $n = "$n\.$d" if $d =~ /\d/; return $n; } # end of subroutine CommaFormatted
If one of our members helps you, please click theicon to add to their reputation!
No support via email or private message - use the forums!
Before you ask, have you Searched?
Cloudjiffy- PaaS for Developers
10-05-2020, 12:30 AM in Web Hosting Forum