develooper Front page | perl.beginners | Postings from October 2009

Re: printf with currency symbols

Thread Previous
From:
Jim Gibson
Date:
October 26, 2009 09:29
Subject:
Re: printf with currency symbols
Message ID:
C70B1C5F.834D%JimSGibson@gmail.com
On 10/26/09 Mon  Oct 26, 2009  8:57 AM, "Bryan R Harris"
<Bryan_R_Harris@raytheon.com> scribbled:

> 
> 
> Is there a good way to do printf's with currency symbols?
> 
> I've tried this:
> 
>   printf "Total: \$%10.2f\n", $total;
> 
> But it puts the dollar sign way out front (ugly).  I want it to look like:
> 
>   Total:    $24.15

You can add a minus sign to the format descriptor to left-justify the field:

%-10.2f

However, if you do this and print more than one line, the decimal points may
not line up.



Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About