I don't quite know what you are doing, besides unnecessarily stringifying your vars. The first example you quote does work, as does the second. All I can suggest is that you go on to eval the string at some point so the $123.45 is evaluated by perl - perl will see the $123 as a var (undef value) and thus leave you with .45 I suspect you have not got warnings turned on as it would be warning you about interpolating an undef string. I suggest you use warnings;. This works as you can see.
$_srp_price = 123.456789; $cost = sprintf "\$%.2f", $_srp_price; $string = "Cost $cost\n"; print $string; __DATA__ Cost $123.46
cheers
tachyon
In reply to Re: Printing a dollar sign..
by tachyon
in thread Printing a dollar sign..
by powerhouse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |