: Mike Blezien
Sent: Sunday, February 12, 2012 10:46 AM
Subject: Re: Formatting Numbers
On 12/02/2012 16:14, Mike Blezien wrote:
>
> Need a little assistance formatting numbers pulled from a databaes. Many
> are like this:
>
> 179550, 45960, 890458 etc.
>
>
On 12/02/2012 16:14, Mike Blezien wrote:
Need a little assistance formatting numbers pulled from a databaes. Many
are like this:
179550, 45960, 890458 etc.
what I need to do is format these values with a comma so they look like
this:
179,550, 45,960, 890,458
What is the easiest way to do thi
Hi Mike,
On Sun, 12 Feb 2012 10:14:42 -0600
"Mike Blezien" wrote:
> Hello,
>
> Need a little assistance formatting numbers pulled from a databaes. Many are
> like this:
>
> 179550, 45960, 890458 etc.
>
> what I need to do is format these values with a comma so they look like this:
>
> 179,5
Pat wrote:
>
> I have been through man printf, info printf and perldoc -f print and still
> can't find how to format numbers.
> In the program below I would like to print the numbers as below:
> 383.3as 383.30
$ perl -le'printf "%.2f\n", 383.3'
383.30
> 37492908 as 37 492 90
I can't test these, but I think they will work. Play around with sprintf a
little bit. Don't forget to check out 'perldoc -f sprintf'.
383.3as 383.30
$var = sprintf("%3.2f",$var)
37492908 as 37 492 908
if($var 1 =~ /(\d{2})(\d{3})(\d{3})/){
$formattedvar = "$1 $