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

Discussion in 'Apache' started by dhaxe, Dec 26, 2008.

  1. #1
    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!
     
    dhaxe, Dec 26, 2008 IP
  2. bille

    bille Peon

    Messages:
    269
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Looks like you have a lot of typos there.

    Try "AddHandler cgi-script .cgi .pl" ( You have cgi-handler ).

    Also, windows is funny about the interpreter line or "shebang" line in a perl script ( like your example #!perl ).

    Not sure '#!perl' is going to work.
     
    bille, Dec 26, 2008 IP
  3. dhaxe

    dhaxe Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your help. You said "a lot of typos" - did you see anything else? I tried changing cgi-handler to cgi-script in the httpd.conf file...still no luck running the hello.pl in a browser.

    Again, though, the file runs just fine using a command line, so I figured my hashbang was correct. I have active perl installed using the default installation options (e.g. it is installed in C:\Perl ).
     
    dhaxe, Dec 26, 2008 IP