PERL script OK at command line, not in browser
I'm attempting to install a simple PERL script. I've tried it on two servers, with the same results on both. If I run the script from the commant line it works fine. When accessing it from a browser all I get output is the text of the file.
Permissions are set correctly on the file (755) and directory (777) it resides in. It's running in the HTML directory of my site (as recommended by the script's author) rather than the cgi-bin, but my server is set up to allow that and I have another script in the same place that works.
Path to perl is correct in the script. print "Content-type: image/gif\n"; is in the script. The file extension is .cgi and that works elsewhere. Syntax checks OK.
Server is running RH Linux/Apache
I'm missing something obvious, I'm sure. I've been searching around the web for an answer, but haven't managed to figure out search terms to use that could lead me to an answer (I get hundreds of pages about other errors).
I'd really appreciate any thoughts you might have.