For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > need help please









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author need help please
HOTFUNINTHACITY@aol.com

2005-04-25, 3:56 am

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 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?




Keith Worthington

2005-04-25, 3:56 am

HOTFUNINTHACITY@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 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?


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
Charles K. Clarkson

2005-04-25, 3:56 am

HOTFUNINTHACITY@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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com