#!/bin/perl

require "cgi-lib.pl";

if (&ReadParse(*input)) {
     print &PrintHeader;
     print "<h1>The solutions to your SWORDS request</h1>";
     $num = length($input{'pat'});
     $ar = "$num $input{'pat'} $input{'max'}";
     $ar =~ s/\W/ /g;                      # untaint the input
     open(PROG,"./swords-simple $ar |");
     print "<OL>";
     while(<PROG>)
       { print $_;
	 print"<br>";
	 }
     print"</OL>";
     }
else {
    print &PrintHeader;
    print <<EOF
<title> Swords </title>
<h1> Swords Word Searching Program</h1><br>
 Type in the word that you want to search for with a
 "_" for an unknown character<hr>
<form method="post" action="/cgi-bin/nik/swords-simple.pl">
<input name = "pat"><p>
Select the maximum number of solutions to return
<SELECT NAME="max"><OPTION SELECTED> 25
<OPTION> 50 <OPTION> 75 <OPTION> 100 </SELECT> <P>
<INPUT TYPE="reset" VALUE="Clear">
<input type="submit" value="Find words!">
</form></html>
EOF
    }
