my $text = "c:/text.pl"; open TEXT, $text or die "Oops can't open $text $!"; open HTML, ">$text.htm" or die "Oops can't write $text.htm $!"; print HTML "
\n";
while () {
   $_ = escapeHTML($_);
   print HTML $_;
}
print HTML "
\n"; close HTML; close TEXT; sub escapeHTML { local $_ = shift; # make the required escapes s/&/&/g; s/"/"/g; s//>/g; # change tabs to 4 spaces s/\t/ /g; # make the whitespace escapes - not required within
 tags  
   s/( {2,})/" " x length $1/eg;
   # make the brower bugfix escapes;
   s/\x8b/‹/g;
   s/\x9b/›/g;
   # make the PERL MONKS escapes (if desired)
   s/\[/[/g;
   s/\]/]/g;
   # change newlines to 
if desired - not required with
   # s/\n/
\n/g; return $_; }