> Robert Citek wrote:
>> Not sure if there is a better way. My guess is that there is probably
>> some module to convert float to currency and then print it as a
>> string. But a quick Google didn't turn up anything.
>
> Here' why (extracted from `perldoc perllocale`):
>
>Category LC_MONET
Robert Citek wrote:
> Not sure if there is a better way. My guess is that there is probably
> some module to convert float to currency and then print it as a
> string. But a quick Google didn't turn up anything.
Here' why (extracted from `perldoc perllocale`):
Category LC_MONETARY: Formattin
I see. You want the output to look something like this:
$ perl -e 'for(my $total = 24.15; $total <3; $total *= 10) {
printf("Total:%10s\n", "\$" . sprintf("%.2f",$total)) ;} '
Total:$24.15
Total: $241.50
Total: $2415.00
Total: $24150.00
Not sure if there is a better way. My guess is
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
wrote:
> Is there a good way to do printf's with currency symbols?
>
> I've tried this:
>
> printf "Total: \$%10.2f\n", $total;
>
On 10/26/09 Mon Oct 26, 2009 8:57 AM, "Bryan R Harris"
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:$
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\