PERL   14

survey

Guest on 30th April 2022 11:45:46 PM

  1. #!/usr/bin/perl -w
  2. #survey.cgi
  3. print "Status:  200 weee\nContent-type: text/html\n\n";
  4.  
  5. use CGI;
  6. $data = new CGI;
  7. $newgod = $data->param("god");
  8.  
  9.  
  10. #
  11. # Open da file for da reading
  12. open(FILE, "<survey.data") or die "Unable to open file";
  13. $index = 0;
  14. while ($god[$index] = <FILE>)
  15. {      
  16.         $count{$god[$index]}++;
  17.         $index++;
  18. }
  19.  
  20. foreach $name (keys %count)
  21. {
  22.         print "Previous answer: $name $count{$name} \n";
  23. }
  24. close(FILE);
  25.  
  26. #
  27. # Open da file for da riting
  28. #
  29. open(FILE, ">survey.data") or die "Unable to open for writing\n";
  30. for($i = 0; $i < $#god; $i++)
  31. {
  32.         print FILE "$god[$i]";
  33. }
  34. print FILE "$newgod\n";
  35. close(FILE);

Raw Paste


Login or Register to edit or fork this paste. It's free.