in reply to Printing a dollar sign..
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Printing a dollar sign..
by powerhouse (Friar) on Aug 26, 2004 at 20:48 UTC | |
by tachyon (Chancellor) on Aug 27, 2004 at 05:21 UTC |