Hello,
The way you "force (a scalar) to float context" in perl is simply use it in numeric context (construct an expression that would require the scalar be used as a number). So the += 0 stuff isn't necessary.
Anywhoo, what you are trying to do works fine in general so you have something funky going on in your code, and you haven't given us enough information to suggest a solution:
$ perl
use warnings;
use strict;
my $retail_rate = 109.98;
my $coupon = 10.05;
my $discounted_rate = $retail_rate + 1;
print "$retail_rate $coupon $discounted_rate\n";
Ctrl-D
109.98 10.05 110.98
Hope this helps,
trwww
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.