Mike
Mike

Reputation: 1610

Perl script wont run; just displays actual code in the browser

I am new to Perl and am having trouble getting my scripts to run properly. Where am I supposed to put the actual Perl scripts in order for them to run correctly? I am testing everything out on my lap top and am trying to call a script from a html page and all I get is the actual script (code) itself displayed in my web browser as opposed to the information that the code is designed to produce. Therefore, I figure I am supposed to put the Perl file somewhere else? Currently I have the Perl script and the HTML file in the same directory. Any help would be greatly appreciated! See below:

 <head>
   <title>Student Web Page</title>
 </head>

 <body>

  <h1>WELCOME! You have reached Kito's Student Web Page</h1>
  <br />
  <p>To run the folloiwing applications, click on the appropriate line:</p>

  <form ACTION="first.pl" METHOD="get">
    <p>
    <input TYPE="submit" VALUE="Step 5 - Perl Environment Variables">
    </p>
  </form>             

#!c:\perl\bin\perl.exe -w
use strict;

print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>Environment Variables</TITLE></HEAD><BODY>";

foreach (keys %ENV) {
    print "<BR><FONT COLOR=green>$_</FONT> is set to <FONT COLOR=red>$ENV{$_}</FONT>";
}

print "</BODY></HTML>";  

Upvotes: 2

Views: 12927

Answers (2)

Twister
Twister

Reputation: 724

Under linux with apache install the mod_cgi module. Under windows with IIS install activestate perl.

Upvotes: 3

Spliffster
Spliffster

Reputation: 7229

You need to configure your webserver to execute the CGI file. How this is done depends on the webserver and operating system.

Some examples: http://www.thesitewizard.com/archive/addcgitoapache.shtml

Upvotes: 8

Related Questions