I'm trying to perl -w the following:

#bonus.cgi - calculates a bonus amount and rcreates a dynamic web page which contains form data & a bonus amount
print "Content-type: text/html\n\n"; 
use CGI qw(:standard);

#prevent Perl from creating undeclared variables
use strict;

#declare variables
my ($name, $sales, $rate, $bonus);

#assign values to variables
$name = param ('Salesperson');
$sales = param ('Sales');
$rate = param ('Rate');

#calculate bonus amount
$bonus = $sales * $rate;

#create web page
print "<html>\n";
print "<head><title>Patton Industries</title><basefont size=5></head>\n";
print "<h1>Bonus Calculation</h1>\n";
print "<body>\n";
print "Salesperson: $name<br />\n";
print "Your bonus is \$$bonus.<br /><br />\n";
print "You entered a sales amount of \$$sales and a \n";
print "bonus rate of $rate.<br />\n";
print "</body>\n";
print "</html>\n";

In several places up and down the DOS response, it tells me "Use of uninitialized value in concatenation (.) or string at bonus.cgi line 'varies'."

I haven't a clue what it's not liking about the code. I've checked it against what the book has several, several times and can find absolutely no discrepency.

9 Years
Discussion Span
Last Post by d5e5

You are running a CGI script. It is expecting data from a CGI form:

$name = param ('Salesperson');
$sales = param ('Sales');
$rate = param ('Rate');

the above scalars will have no values (they are uninitialized).

Why are you running a CGI script from the command line? That is OK to check for certain errors but CGI scripts are meant to run in a client /server environment (like http). The CGI module can accept arguments from STDIN so you can run and check CGI script from the command line, read the CGI.pm module documentation. Or you can define values for the input:

$name = param ('Salesperson') || 'Tom';
$sales = param ('Sales') || 100;
$rate = param ('Rate') || 5;

that will at least give you something to work with for now.


For whatever reason, that's the way the instructor wants us to check further to ensure that it's running properly (after a perl -c). It doesn't seem to be the most idealistic to me, but I'm a newb to Perl.

The page it's actually in is:

<html />
<head /><title />Patton Industries</title></head>
<body bgcolor="#FFFFCC" />
<h2 />Bonus Calculator</h2>
<form action="http://localhost/cgi-bin/chap03/bonus.cgi" method="get" />

<table />
<tr />
<td />Salesperson name:</td>
<td /><input type="text" name="salesperson" size="30" /></td>

<tr />
<td />Sales amount:</td>
<td /><input type="text" name="sales" size="10" /></td>

<tr />
<td />Bonus rate:</td>
<td /><input type="text" name="rate" size="10" /></td>

<p><input type="submit" value="Submit" /> <input type="reset" /></p>


But when you hit "Submit", it just shows the perl scripting.


I was under the impression that I could do it w/ Win XP Pro if IIS is installed.


You can, but IIS has to be setup/configured to run CGI scripts. You can ask how to do that on a IIS forum if you don't already know how. I persoanlly don't know much about IIS so can't help you in that regards.


I'm a new writer script with Perl. Anyone can help me with this error below:
Use of uninitialized value within @allday in concatenation (.) or string at /usr/lib/cgi-bin/user/invoice.pl line 98.
Use of uninitialized value within @allday in hash element at /usr/lib/cgi-bin/user/invoice.pl line 99

Line 97:for $day (0..(@allday)) {
Line 98: print"{\\footnotesize $allday[$day]}&\n";
Line 99: unless(defined($tots{$allday[$day]})) { $tots{$allday[$day]} = 0; }


Please start a new thread to ask your question instead of replying to a three-year old thread.

When you post your question, please include your script, invoice.pl, wrapped in [CODE]Your invoice.pl script goes here[/CODE] tags. We can't help you with this kind of error unless we know what you are trying to do and how you are trying to do it.

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.