title: Creating a comment box html form with perl processing script
body: <p>I currently have a script named "test.pl" that does a variety of things and prints out HTML code to view on a webpage. One of the things I want it to do, is allow the user to type in a comment, and select which type of comment it is and the processing form of the comment box will append the comment into a file. I am not sure if I am doing this right because it doesn't seem to be working as I'm getting some errors.. here are the snippets of the code:</p>
  
  <pre><code>#!/usr/bin/perl
  use warnings;
  use CGI qw(:cgi-lib :standard);  # Use CGI modules that let people read data passed from a form
  
  #Initiate comment processing
  &amp;ReadParse(%in);
  if ($in("comment") &amp;&amp; $in("type") ! == "") {
      $comment = $in("comment");
      $type = $in("type");
      WritetoFile($comment,$type);
  }
  
  sub WritetoFile {
      my $input = shift;
      my $type = shift;
      my $file = "$type" . "_comment.txt";
      open (my $fh, '&gt;&gt;', $file) or die "Could not open file '$file' $!";
      print $fh "$input\n";
      close $fh
  }   
  </code></pre>
  
  <p>The form I am using is this:</p>
  
  <pre><code>&lt;FORM ACTION=test.pl METHOD=POST&gt;
  Comment:
  &lt;INPUT TYPE=TEXT NAME="comment" LENGTH=60&gt;
  &lt;P&gt;
  Select Type
  &lt;SELECT NAME ="type"&gt;
  &lt;OPTION SELECTED&gt; Animal
  &lt;OPTION&gt; Fruit
  &lt;OPTION&gt; Vegetable
  &lt;OPTION&gt; Meat
  &lt;OPTION&gt; Other
  &lt;INPUT TYPE=SUBMIT VALUE="Submit"&gt;&lt;/FORM
  </code></pre>
  
  <p>Any suggestions on how to make this work or even improve the process I am doing would be greatly appreciated!I would prefer to keep the processing script and the script that does the rest of my subs to be the same script (test.pl) unless this is something I have to keep separate</p>