title: I have a perl script that is passing a parameter in from an html file and then prints that parameter to the file
body: <p>So I have written a perl scrip to pass a parameter from an HTML file and then take that vaule of the parameter and write it to a file, then read the file and complie the data. here is the body of the html file: </p>
  
  <pre><code>    &lt;!DOCTYPE html&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html lang = "en"&gt;
  &lt;head&gt;
  &lt;title&gt; poll.html &lt;/title&gt;
  &lt;meta charset = "utf-8" /&gt;
  &lt;style type = "text/css"&gt;     
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;!-- the quiz --&gt;
  &lt;body&gt;
  &lt;form action = "../cgi-bin/poll.pl" method = "post"&gt;
  &lt;/h1&gt; this is a poll&lt;br&gt;&lt;br&gt;What is your favorite color?&lt;/h1&gt;
  &lt;input type="radio" name="color" value="red"&gt;Red&lt;br&gt;
  &lt;input type="radio" name="color" value="green"&gt;Green&lt;br&gt;
  &lt;input type="radio" name="color" value="blue"&gt;Blue&lt;br&gt;
          &lt;input type = "submit"  value = "Submit Quiz" /&gt;
  
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>then I have my perl script which all works but once I open my file I lose the value of $color I tried making $color a global varable but the same error occurred (Use of uninitialized value $color in concatenation (.) or string at poll.pl line 19.) here is the perl script:
      #!/usr/bin/perl -w</p>
  
  <pre><code># processOrder.pl
  use CGI ":standard";
  use strict;
  use warnings;
  print header;
  print start_html("Pizza Places Order Form");
  #Set local variables to the parameter values 
  our($color)=param("color");
  my $filename = 'data.txt';
  open(my $fh, '+&gt;&gt;', $filename) or die "Could not open file '$filename' $!";
  print $fh "'$color'\n";
  my $red = 0;
  my $blue = 0;
  my $green = 0;
  while( my $line = &lt;$fh&gt;)  {   
      if (index($line, "red\n") != -1) {
      $blue = $blue + 1;} 
  if (index($line, "blue\n") != -1) {
      $blue = $blue + 1;}
  if (index($line, "gren\n") != -1) {
      $green = $green + 1;}
  }
  my $total = $red + $green +$blue;
  if ($total == 0){
  $total = 1}
  print  h4("percent blue = ", $blue/$total, "\n");
  print  h4("percent green = ", $green/$total,  "\n");
  print  h4("percent red = ", $red/$total, "\n");
  close $fh; 
  </code></pre>
  
  <p>final warning im new to perl but I do think that this logic is sound any help would be great. Thanks </p>