#!/usr/bin/perl # # Globals # use vars qw/$deftext %opt /; # # Command line options processing # sub init() { use Getopt::Std; my $opt_string = 'hpci:o:t:j:'; getopts( "$opt_string", \%opt ) or usage(); usage() if $opt{h}; } # # Message about this program and how to use it # sub usage() { print STDERR << "EOF"; touchhtml -- Create a barebones HTML file usage: $0 [-hpc][-i ][-o ][-t ] -h : This (help) message -p : Add <pre> tags -c : Print "Content-type" at the start (for CGI) -i FILE : Read body from given filename -o FILE : Output to given filename -t TITLE : Set the HTML <TITLE> field to given title -j FILE : Include this JavaScript filename in the body EOF exit; } init(); if (!$opt{o}) { open(FILEH, ">-"); } else { open(FILEH, ">$opt{o}") || die "Cannot open file for writing!"; } if ($opt{c}) { print "Content-type: text/html\n\n"; } print FILEH <<FOO; <HTML> <HEAD> <TITLE>$opt{t} FOO print FILEH "
\n" if $opt{p};
if ($opt{i})
{
	open (INFILE, "<$opt{i}") || die "Cannot open file for reading!";
	while ()
	{
		print FILEH;
	}
	close(INFILE);
}
elsif (!(-t STDIN))
{
	while ()
	{
		print FILEH;
	}
}
print FILEH "
\n" if $opt{p}; print FILEH "\n" if $opt{j}; print FILEH < FOO close(FILEH);