Code Comments
Programming Forum and web based access to our favorite programming groups.Hi My program is to send data using an online form. I have the web page for the form. But the web page does not receive the data from the cgi file. I check my work in DOS. When I type perl -c bonus.cgi I get a message tell me syntax ok. But when I check with : perl -w bonus.cgi I get this under <BODY>: Use of uninitialized value in multiplication <*> at -----.cgi line 00 Your bonus is $0.00<BR><BR> You entered a sales amount of $0.00 and a Use of uninitialized value in muliplycation <*> at ----.cgi line 00 bonus rate of 0.00<BR> this is the body part as shown in my chapter of my college course study boo k in the -----.cgi file.. printf "Your bonus is \$%.2f.<BR><BR>\n", $bonus; printf "You entered a sales amount of \$%.2f and a \n", $sales; printf "bonus rate of %.1f%%.<BR>\n", $rate * 100; Is this a error in my book or a bug in my Perl program?
Post Follow-up to this messageHOTFUNINTHACITY@aol.com wrote: > Hi > > My program is to send data using an online form. > > I have the web page for the form. But the web page does not receive the > data from the cgi file. > I check my work in DOS. When I type perl -c bonus.cgi > I get a message tell me syntax ok. > But when I check with : perl -w bonus.cgi I get this under <BODY>: > > Use of uninitialized value in multiplication <*> at -----.cgi line 00 > Your bonus is $0.00<BR><BR> > You entered a sales amount of $0.00 and a > Use of uninitialized value in muliplycation <*> at ----.cgi line 00 > bonus rate of 0.00<BR> > > this is the body part as shown in my chapter of my college course study b ook > in the -----.cgi file.. > > printf "Your bonus is \$%.2f.<BR><BR>\n", $bonus; > printf "You entered a sales amount of \$%.2f and a \n", $sales; > printf "bonus rate of %.1f%%.<BR>\n", $rate * 100; > > Is this a error in my book or a bug in my Perl program? I am a newbie myself but if I were in your situation this is what I would check/try. Do you have "use strict;" and "use warnings;" at the beginning of your code? Where are $bonus and $rate defined? The error message indicates that there is a problem with the multiplication on the first line but I do not see any multiplication in the code that you provided. The lack of error message regarding $sales and the assumption that $bonus = $sales * $rate; leads me to believe that $rate didn't get set somewhere. Put something like my ($bonus, $sales, $rate) = (10.00, 100.00, 0.10); print " Bonus: $bonus\n"; print " Bonus: $sales\n"; print " Bonus: $rate\n"; Before the section you provided. If the error goes away remove the first line and try again. Admittedly that is a brutally simple debugging technique but it may help. HTH -- Kind Regards, Keith
Post Follow-up to this messageHOTFUNINTHACITY@aol.com <mailto:HOTFUNINTHACITY@aol.com> wrote: : I have the web page for the form. But the web page does not : receive the data from the cgi file. : I check my work in DOS. When I type perl -c bonus.cgi : I get a message tell me syntax ok. : But when I check with : perl -w bonus.cgi I get this under : <BODY>: : : Use of uninitialized value in multiplication <*> at -----.cgi : line 00 : Your bonus is $0.00<BR><BR> : You entered a sales amount of $0.00 and a : Use of uninitialized value in muliplycation <*> at ----.cgi line : 00 : bonus rate of 0.00<BR> That doesn't look right. Is that edited? There shouldn't be a line 00. And "multiplication" is spelled wrong in one error message. Show us the unedited error messages or tell us that you edited things. Leaving out key details is a Bad Thing. : this is the body part as shown in my chapter of my college course : study book in the -----.cgi file.. : : printf "Your bonus is \$%.2f.<BR><BR>\n", $bonus; : printf "You entered a sales amount of \$%.2f and a \n", $sales; : printf "bonus rate of %.1f%%.<BR>\n", $rate * 100; : : Is this a error in my book or a bug in my Perl program? It's an error in the program you wrote. We don't know if it is also in your text book without a comparison. Does your teacher allow you to get help from email lists? HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.