/home/wpollock1/public_html/restricted/ShellScripting/text2html.pl

#!/usr/bin/perl -TW
# text2html - This filter script reads text input and
# converts to HTML.
#
# Written 3/2007 by Wayne Pollock, Tampa Florida USA.

@ARGV = ( "-" ) unless @ARGV;

while ( $filename = shift @ARGV )
{

    unless ( open( FILE, "< $filename" ) )
    {
       warn "$filename: $!";
       next;
    }

    $filename = "STDIN" if ( $filename eq "-" );

    print <<"End_Prolog";
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>$filename</title>
  </head>
  <body>
    <pre>
End_Prolog

    while ( <FILE> )
    {
        s/&(?!amp;)/&amp;/g;

        s/</&lt;/g;

        s/>/&gt;/g;
        print;
    }

    print <<"End_Epilog";
    </pre>
  </body>
</html>
End_Epilog

    close( FILE );
}