| #!/usr/bin/perl
use CGI; 
$query  = new CGI;
$act    = $query->param('act');
$string = $query->param('string');
$query1 = $query->param('query');
if ( $act eq "Search String" ) {
  # Print HTML.
  print ( "Content-type: text/html\n\n" );
  # Use "here-doc" syntax.
  print <<EndofHTML;
  <html>
   <body>
    <table width="100%" height="80%">
     <tr>
      <td align="center">
       <font size="+0">
EndofHTML
  # Remove leading and trailing spacing.
  $string =~ s/^\s*(\S*)\s*$/$1/;
  $query1 =~ s/^\s*(\S*)\s*$/$1/;
  # For security, remove some Unix metacharacters.
  $string =~ s/;|>|>>|<|\*|\?|\&|\|//g;
  $query1 =~ s/;|>|>>|<|\*|\?|\&|\|//g;
  # Compose a Java command.
  $cmd    =  "/usr/bin/java SearchString '" . $string . "' '" . $query1 . "'";
  print( $cmd );    system( $cmd );
  print <<EndofHTML;
        <form> 
         <input type="button" value=" Back " onclick="history.go(-1);return false;" />
        </form>
       </font>
      </td>
     </tr>
    </table>
   </body>
  </html>
EndofHTML
}
elsif ( $act eq "HTML source" ) {
  print ( "Content-type: text/plain\n\n" );
  $cmd  = "/usr/bin/lynx -dump -source " . $ENV{HTTP_REFERER}; 
  $cmd .= "; echo \n\n\n\n";
  system( $cmd );
}
elsif ( $act eq "Perl source" ) {
  print ( "Content-type: text/plain\n\n" );
  system( "/bin/cat SearchString.pl; echo \n\n\n\n" );
}
elsif ( $act eq "Java source" ) {
  print ( "Content-type: text/plain\n\n" );
  system( "/bin/cat SearchString.java; echo \n\n\n\n" );
}
elsif ( $act eq "Help" ) {
  print ( "Content-type: text/html\n\n" );
  system( "/bin/cat  Help.html" );
}
else {
  print( "Content-type: text/html\n\n" );
  print( "No such option: <em>$act</em>" );
} |