#!/usr/local/bin/perl
#
# template.cgi - A sample CGI script that generates pages with the
# same look-and-feel as the CS Departmental Pages. This script
# uses the supplied template.html file to properly set the page
# title, owner, and email address.
#
# robh 10/2001
#
#
# Define the template file you wish to use
#
$template="/l/www/Support/samples/template.html";
#
# Define the custom information you want to use
#
$title="Sample page title here";
$name="Joe Doe";
$email="joedoe";
#
# Define a subroutine to generate your custom content
#
sub generate_content {
print "
Your content goes here
";
}
#
# Generate the Content-type header
#
print "Content-type: text/html\n\n";
#
# Print out the template, filling in the custom information as
# We find the placeholders in the template.
#
open(TEMPLATE,"< $template") || die "unable to open $template";
while () {
# Insert our title
if (/^(.*)__TITLE__(.*)$/) {
print "$1$title$2\n";
}
# Insert our name and email
elsif (/^(.*)__EMAIL__(.*)__NAME__(.*)$/) {
print "$1$email$2$name$3\n";
}
# Insert our content
elsif (/^(.*)__CONTENT__(.*)$/) {
generate_content();
}
# We don't care about the 'Last Modified' tag for cgi
elsif (/^(.*)Last Modified:.*$/) {
print "$1\n";
}
# Else, just print the line
else {
print;
}
}
#
# Our work here is done
#
exit;