#!/usr/bin/perl ############################################################################### # template: Generate html pages from combination of template and content file # # This script can run and take argument either: # - from HTML form, through the use of the param(), or # - from terminal input, through the use of @ARGV. # Syntax: template [template.name] [content.name] > [output.html] # # author: Sam Sultan ############################################################################### $tmplDir = "/home/s/sultans/web/demo/perl/template"; $contDir = "/home/s/sultans/web/demo/perl/template"; use CGI "param"; if (@ARGV) { #if coming from terminal $template = $ARGV[0]; $content = $ARGV[1]; } else { #if coming from HTML form $template = param("template"); $content = param("content"); print "Content-type: text/html\n"; print "\n"; } &printHtml(); #call sub to produce html ############################################################################### # printHtml: Reads an html template, and search for a content insert point ############################################################################### sub printHtml { open(TEMPLATE, "<$tmplDir/$template") || #open template html file print("Cannot open $tmplDir/$template for input"); while (