Forum Moderators: phranque

Message Too Old, No Replies

Trouble getting Perl (.pl) files to run in a browser

         

dhaxe

12:39 am on Dec 27, 2008 (gmt 0)

10+ Year Member



I have ActivePerl and Apache installed (and working as best as I can tell). The below code runs fine when I call Hello.pl in cmd, but when I try to open Hello.pl in any web browser, it just displays the script/code (or, in chrome, automatically downloads Hello.pl).

______________________________
#!perl
print "Content-type: text/html \n\n"; #HTTP HEADER
print "Hello";
______________________________

Also, I'm on a windows (xp) machine, running Apache 2.0 (using XAMPP win32-1.7.0). I put these lines in the apache httpd.conf:
______________________________
Options +ExecCGI
AddHandler cgi-handler .cgi .pl
______________________________

Any help would be greatly appreciated ...happy holidays!

jdMorgan

2:19 pm on Dec 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remove the space character after 'html' and before the "\n\n". Also, try either removing the comment, or moving it to a new line.

# HTTP HEADER
print "Content-type: text/html\n\n";

If this makes no difference, then the problem is likely in the server configuration, not in the script.

Jim

Caterham

2:22 pm on Dec 27, 2008 (gmt 0)

10+ Year Member



it just displays the script/code

It looks like the cgi-handler is not invoked.

I put these lines in the apache httpd.conf:

Where did you put the Options directive (appropriate <director> container)? Did you restart apache so that the changes take effect?