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

Re: printf with currency symbols

Thread Previous | Thread Next
From:
Robert Citek
Date:
October 26, 2009 11:08
Subject:
Re: printf with currency symbols
Message ID:
4145b6790910260927w732607bepfd5e12327cc66080@mail.gmail.com
Is this what you are looking for:

$ perl -e '$total = 24.15 ; printf "Total: \$%.2f\n", $total; '

Regards,
- Robert

On Mon, Oct 26, 2009 at 11:57 AM, Bryan R Harris
<Bryan_R_Harris@raytheon.com> wrote:
> 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
>
> Is there a way to do this without getting all messy like this?
>
>  printf "Total:%10s\n", "\$".sprintf(%.2f,$total);

Thread Previous | Thread Next


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