Online Learning Applications for Technical English


Home
Syllabus
Assignments

Instructor



Producing Homepages

If you want to write a Perl CGI program to put "Hello, world" on a homepage, you need to do two things:
  • Write the Content-type (MIME) header for homepages
  • Write the HTML source
Filename: hello.cgi
#!/usr/bin/perl

#------------------------------
# [10/30/2002] - File created.
#------------------------------

#------------------------------------------------
# Step 1:  Print MIME type header for homepages.
#------------------------------------------------
  print "Content-type:  text/html\n\n";

#------------------------------------------------
# Step 2:  Print HTML contents.
#------------------------------------------------
  print "<HTML>\n";
  print "<HEAD>\n";
  print "</HEAD>\n";
  print "<BODY>\n";
  print "Hello, world!\n";
  print "</BODY>\n";
  print "</HTML>\n";

  exit;
[ View result ]

Note 1: You must have the correct Perl path in the first line after the #! characters.

[ Back ]