CGI-Programming

Creating a Web page "on the fly" by a CGI-program

Program hello.cgi

#!/usr/bin/perl

$first_name = "Karin";
$last_name = "Obsfeld";
$phone  = "4961";

print "content-type: text/html\n\n";


print "<HTML>\n",
      "<HEAD>\n",
      "<TITLE>Say Hello<\/TITLE>\n",
      "<\/HEAD>\n",
         
      "<BODY>\n",
         
      "<H2>Say Hello<\/H2>\n",
      "Hi $first_name!<P>\n",
      "Your details:<P>\n",
      "Name: $first_name $last_name<BR>\n",
      "Phone number: $phone\n",

      "<\/BODY>\n",
      "<\/HTML>\n";

Note:

To quote multi-line strings, you may also use the here-document construct instead of double quotes.

To browse the web page, use the URL:

This is the Perl script. To execute it, click here .


Table of Contents.
Previous | Next.