The script itself looks syntax-wise, fine. Your problem is, you have it so it there's a param, that it will call the word_count sub routine. However, you lack the proper header output, as you have done correctly in the print_form sub routine if there is no param. Thus, you are not outputting any header and the script will therefore fail to run in a CGI environment. That is the cause for that particular error anyhow. I didn't look at the code other than in regards to that error (as I don't have the time nor desire to, even if it is simple and short), so I can't comment on other aspects or suggest anything, let alone to assume or state you have done something well or incorrectly. I get the impression this is an assignment for the sake of you being taught anyway, so I'll leave it to your instructor. Though I just simply looked for the cause of this error, this doesn't seem bad for someone learning. Good job.