# perl script to convert particularly formatted plain text email & URL list files
#  into nicely indented HTML with active links
# written by earl 11/29/96
# to run under unix, "perl this_scripts_name <plain_file_in >out.html"
print "<HTML>\n<BODY>\n"; # HTML preamble
print "<UL>\n"; # begin first indentation level
$indentlevel = 0; # call it number 0
$lws[0] = 0;      # assume it corresponds to no leading whitespace in the
# original plaintext
while ($linein=<STDIN>) { # read in another line
	$testblank = $linein;
	$testblank =~ s/\s*//g ; # try stripping out out all the whitespace
	if ( $testblank ) { # if nothing would be left, skip this line
		$leadingws = $linein;
		$leadingws =~ s/(\s*)(.*)(\n)/$1/; #pull out leading whitespace
		while (length($leadingws)<$lws[$indentlevel]) {
			print "</UL>"; # unindent 1 level
			$indentlevel -= 1;
		}
		if (length($leadingws)>$lws[$indentlevel]) {
			$indentlevel += 1; #indent 1 level
			$lws[$indentlevel]=length($leadingws);
			print "<UL>";
		}
		print "<LI>"; # start new item in indented list
		# magically activate URLs to links
		$linein =~ s/http:\/\/(\S*)/<A HREF="$&">$&<\/A>/g ;
		# magically activate email addresses to links
		$linein =~ 
			s/(\s)((\S+)\@(\S+))/$1<A HREF="mailto:$2">$2<\/A>/g ;
		print $linein; # output the altered line
	}
}
while ($indentlevel>=0) { # unindent back to 0
	print "</UL>";
	$indentlevel -= 1;
}
print "\n";
print "<P><HR>Converted to HTML by ";
print "<A HREF=\"http://projects.zillabit.com\">earl</A>'s ";
print "little PERL script.\n";
print "</BODY>\n</HTML>\n"; # HTML postamble
