CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Minus not working...

 



DippinPete
Deleted

Jan 17, 2001, 8:26 AM

Post #1 of 9 (716 views)
Minus not working... Can't Post

Ok... why would
$fiddler = $grand_total - $take_off;

Not work if I can get a result with:
print $grand_total;
print $take_off;
(they are getting the values passed)

I just need to subtract $take_off from grand_total.

Thanks,

Pete



sttring
Deleted

Jan 17, 2001, 8:44 AM

Post #2 of 9 (712 views)
Re: Minus not working... [In reply to] Can't Post

The result of $grand_total - $take_off is the value of $fiddler. To print the result you would need to print $fiddler

print $fiddler; #prints result

sttring



DippinPete
Deleted

Jan 17, 2001, 8:57 AM

Post #3 of 9 (708 views)
Re: Minus not working... [In reply to] Can't Post

LOL!

Thanks, but that's not the problem.

$fiddler does not print the correct value!

In other words.

IF
$grand_total is equal to 10
and
$take_off is equal to 4
then
$fiddler should be equal to 6.

If I do a print for take off and grand total I get the 4 and the 10, but when I do a print for fiddle I get -4

Thanks,

Pete



parham_m_s
journeyman

Jan 17, 2001, 8:59 AM

Post #4 of 9 (707 views)
Re: Minus not working... [In reply to] Can't Post

maybe it's cuz u'r subtracting strings...



sttring
Deleted

Jan 17, 2001, 9:10 AM

Post #5 of 9 (706 views)
Re: Minus not working... [In reply to] Can't Post

Pete, can you post a copy of your code here? I just tried it and it worked fine for me.

parham, he isn't subtracting strings. He is subtracting scalar variables that are assigned to numbers.

sttring


DippinPete
Deleted

Jan 17, 2001, 9:21 AM

Post #6 of 9 (705 views)
Re: Minus not working... [In reply to] Can't Post

Sure...

$take_off_this_much = ($coupon_amount/100) * $subtotal;
print $take_off_this_much; #THIS WORKS
print $grand_total; #THIS WORKS
$fiddler = $grand_total-$take_off_this_much;
print $fiddler; #THIS DOES NOT WORK, prints $take_off_this_much in negative form (i.e. -4)

Thanks,

Pete




(This post was edited by DippinPete on Jan 17, 2001, 8:23 AM)


sttring
Deleted

Jan 17, 2001, 9:37 AM

Post #7 of 9 (700 views)
Re: Minus not working... [In reply to] Can't Post

Where in your code is the variable $grand_total defined? $grand_total appears to be undefined in your code.

sttring



DippinPete
Deleted

Jan 17, 2001, 10:05 AM

Post #8 of 9 (698 views)
Re: Minus not working... [In reply to] Can't Post

$grand_total is defined this is proven in that when
the line:
print $grand_total;
is used the correct amount is diplayed.

Thanks.

Pete



DippinPete
Deleted

Jan 17, 2001, 11:00 AM

Post #9 of 9 (692 views)
Re: Minus not working... [In reply to] Can't Post

All fixed.

My bad.

$grand_total was printing within an array that was adding a "$" in front.

Thanks for all the help.

It was that 'hint' that made me look deeper!

Pete


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives