Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CGI and HTML

Status
Not open for further replies.

samesale

Programmer
Sep 15, 2003
133
US
I have created the following program. However, it gives me the error at the end of the program.

#!/usr/bin/perl -w

use CGI;
$query = new CGI;
#pollr.cgi

$guest_file= "item2.out";
$counti2=0;
$counti2++;
$d ="\$";

print $query->header;

open(INF,"poll.out") or dienice("Couldn't open survey.out for reading: $! \n");

@data = <INF>;
close(INF);

# First we initialize some counters and hashes for storing the
# summarized data.
$count =0;
$commentary =&quot;&quot;;
$media1 =0;
$media2 =0;
$media3 =0;
$media4 =0;
$media5 =0;
$media6 =0;
$media7 =0;
$media8 =0;
$reason1 =0;
$reason2 =0;
$reason3 =0;
$reason4 =0;
$reason5 =0;
$opinion1 =0;
$opinion2 =0;
$opinion3 =0;
$opinion4 =0;
$opinion5 =0;
$opinion6 =0;
$opinion7 =0;
$commentt =0;

foreach $i (@data) {
chomp($i);
($media,$reason,$opinion,$comment,$month,$day,$year)=split(/\|/,$i);

# this is the same as $count = $count + 1;

$counti2++;

if ($media eq &quot;WUPS&quot;) { $media1 = $media1 +1};
if ($media eq &quot;WCXY&quot;) { $media2 = $media2 +1};
if ($media eq &quot;WMMI&quot;) { $media3 = $media3 +1};
if ($media eq &quot;news&quot;) { $media4 = $media4 +1};
if ($media eq &quot;Friend&quot;) { $media5 = $media5 +1};
if ($media eq &quot;salebyyou&quot;) { $media6 = $media6 +1};
if ($media eq &quot;billboard&quot;) { $media7 = $media7 +1};
if ($media eq &quot;other&quot;) { $media8 = $media8 +1};

if ($reason eq &quot;buy&quot;) { $reason1 = $reason1 +1};
if ($reason eq &quot;sell&quot;) { $reason2 = $reason2 +1};
if ($reason eq &quot;buysell&quot;) { $reason3 = $reason3 +1};
if ($reason eq &quot;curiosity&quot;) { $reason4 = $reason4 +1};
if ($reason eq &quot;other&quot;) { $reason5 = $reason5 +1};

if ($opinion eq &quot;inexeasy&quot;) { $opinion1 = $opinion1 +1};
if ($opinion eq &quot;inexhard&quot;) { $opinion2 = $opinion2 +1};
if ($opinion eq &quot;expeasy&quot;) { $opinion3 = $opinion3 +1};
if ($opinion eq &quot;exphard&quot;) { $opinion4 = $opinion4 +1};
if ($opinion eq &quot;Noopin&quot;) { $opinion5 = $opinion5 +1};
if ($opinion eq &quot;Confus&quot;) { $opinion6 = $opinion6 +1};
if ($opinion eq &quot;Other&quot;) { $opinion7 = $opinion7 +1};

if ($comment eq &quot; &quot;) { $commentt = $commentt + 1 };


# Now we can print out a web page summarizing the data.

<html><head><title>Survey Results</title></head><body>

<h2 align=CENTER>Survey Results</h2>

Total visitors: $counti2<p>

How did you learn about this site?

<ul>
<li> &quot;WUPS =&quot; $media1
<li> &quot;WCZY =&quot; $media2
<li> &quot;WMMI =&quot; $media3
<li> &quot;Newpaper =&quot; $media4
<li> &quot;Friend =&quot; $media5
<li> &quot;Contacted =&quot; $media6
<li> &quot;Billboard =&quot; $media7
<li> &quot;Other =&quot; $media8
</ul>

<ul>
<li> &quot;Buy =&quot; $media1
<li> &quot;Sell =&quot; $media2
<li> &quot;Buy/Sell =&quot; $media3
<li> &quot;Curiosity =&quot; $media4
<li> &quot;other =&quot; $media5
</ul>

<ul>
<li> &quot;Inexpensive - Easy =&quot; $opinion1
<li> &quot;Inexpensive- Hard =&quot; $opinion2
<li> &quot;Expensive - Easy =&quot; $opinion3
<li> &quot;Expensive - Hard =&quot; $opinion4
<li> &quot;No Opinion =&quot; $opinion5
<li> &quot;Consfused =&quot; $opinion6
<li> &quot;Other =&quot; $opinion7
</ul>

print <<EndHTML;

sub dienice {
my($msg) = @_;
print &quot;<h2>Error</h2>\n&quot;;
print $msg;
exit;
}

ERROR IS:

Unquoted string &quot;head&quot; may clash with future reserved word at pollr.cgi line 81. Bareword found where operator expected at pollr.cgi line 81, near &quot;

Please help.
 
print <<EndHTML;

should be before your plain text info.

Then at the end put

EndHTML

on its own line.
 
Thank you very much. It worked. I really appreciate your time and help. This forum is the greatest and the contributors are great for giving their time. I want to thank you and all other who have helped before.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top