This line represents the server's path to PERL:
#!/usr/local/bin/perl

The following section takes information from the form:
if ($ENV{'REQUEST_METHOD'} eq 'POST') {

      # Get the input

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

      # Split the name-value pairs

@pairs = split(/&/, $buffer);

      # Load the FORM variables

foreach $pair (@pairs) {
      ($name, $value) = split(/=/, $pair);
      $value =~ tr/+/ /;
      $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

      $FORM{$name} = $value;
}
}

print "Content-type: text/html\n\n";

The following looks for and opens "poll.dat"
if(-e "poll.dat")
{
      open(POLL, "poll.dat");
}

while(<POLL>)
{
      push(@poll, $_);
}
close(POLL);

The following defines how each line of data will be written:
@lines = ("1");
foreach $each_line (@lines)
{
      $this_line = "line" . $each_line;
      $$this_line = $poll[$each_line-1];
      chop($$this_line);
}

If the first line has no value, write 0 (tab) 0 (tab) 0
if($line1 eq " ")
{
      $line1 = "0\t0\t0";
}

@line1_answers = split(/\t/, $line1);

If the user answered yes, increase line 1 by 1
if($FORM{'QUESTION'} eq "yes")
{
      $line1_answers[0]++;
}

If the user answered no, increase line 2 by 1
elsif($FORM{'QUESTION'} eq "no")
{
     $line1_answers[1]++;
}

If the user answered maybe, increase line 3 by 1
elsif($FORM{'QUESTION'} eq "maybe")
{
     $line1_answers[2]++;
}

Open poll.dat and print the new numbers
open(POLL, ">poll.dat");
print POLL "$line1_answers[0]\t$line1_answers[1]\t$line1_answers[2]\n";
close(POLL);

Start printing HTML to a page for display
print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>POLL RESULTS</TITLE>\n";
print "</HEAD>\n";
print "<BODY BGCOLOR=FFFFCC>\n";
print "<CENTER><H2>Poll Results</H2></CENTER>\n";
print "<h3>Would You Go To The North Poll?</h3><BR>\n";


The table code starts here
print "<TABLE BORDER=1 cellpadding=5 cellspacing=1>";

print "<TR>";
print "<TD><b>Answer</b></TD><TD><b>Number</b></TD><TD><b>Percentage</b></TD><TD><b>Visual</b></TD>";
print "</TR>";

The yes answer row starts here - the next three rows of answers work just this way
print "<TR>";
print "<TD>";
print "Yes: ";
print "</TD>";

Print the number of yes answers in poll.dat's line one
print "<TD>";
print $line1_answers[0];
print "</TD>";

Add all the yes, no, and maybe answers, divide them into the yes answers and times it by 100
print "<TD>";
print $line1_answers[0] / ($line1_answers[0] + $line1_answers[1] + $line1_answers[2])*100;

Add the percentage sign
print "%";
print "</TD>";

Create an image with a height set to 7 and a width set to the same percentage figured above.
print "<TD>";
print "<IMG SRC=/pollred.gif height=7 width=";
print $line1_answers[0] / ($line1_answers[0] + $line1_answers[1] + $line1_answers[2])*100;
print " ALT=Yes answers>";
print "</TD>";
print "</TR>";

The No answers start here
print "<TR>";
print "<TD>";
print "No: ";
print "</TD>";

print "<TD>";
print $line1_answers[1];
print "</TD>";

print "<TD>";
print $line1_answers[1] / ($line1_answers[0] + $line1_answers[1] + $line1_answers[2])*100;
print "%";
print "</TD>";

print "<TD>";
print "<IMG SRC=/pollblue.gif height=7 width=";
print $line1_answers[1] / ($line1_answers[0] + $line1_answers[1] + $line1_answers[2])*100;
print " ALT=No answers>";
print "</TD>";
print "</TR>";

The Maybe answers start here
print "<TR>";
print "<TD>";
print "Maybe: ";
print "</TD>";

print "<TD>";
print $line1_answers[2];
print "</TD>";

print "<TD>";
print $line1_answers[2] / ($line1_answers[0] + $line1_answers[1] + $line1_answers[2])*100;
print "%";
print "</TD>";
print "<TD>";
print "<IMG SRC=/pollgreen.gif height=7 width=";
print $line1_answers[2] / ($line1_answers[0] + $line1_answers[1] + $line1_answers[2])*100;
print " ALT=Maybe answers>";
print "</TD>";
print "</TR>";

Total number of answers is figured by adding the yes, no , and maybe answers in poll.dat
print "<TR>";
print "<TD colspan=4>";
print "Total Number of Answers: ";
print $line1_answers[0] + $line1_answers[1] + $line1_answers[2];
print "</TD>";
print "</TR>";

print "</TABLE>";

Write the copyright statement
print "<P>This poll script copyright 1999, Joe Burns, Ph.D.";

Finish the HTML code
print "</BODY>\n";
print "</HTML>\n";