CGI-Programming

Creating a static HTML file by a Perl program

Program hello.pl

#!/usr/bin/perl

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

$html_file = "/var/www/hello.html";
open (FH, ">$html_file") || die "cannot open \"$html_file\": $!";

print FH "<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";
         
close (FH);         

To browse the Web page, use the link:

hello.html


Table of Contents.
Previous | Next.