#!/usr/local/bin/perl # # search.pl # version 961211 # copyright 1996 by bo larsson # all rights reserved # # this CGI program will search a text file for the desired string and generate # an html table on-the-fly. The text file should have tab-delimited fields and # return-delimited records. # # bugs or feedback to bliss@seagull.net # for information on how to use, visit http://www.seagull.net/bliss/ # what does the user want to find? ($dump,$search) = split(/=/,$ENV{'QUERY_STRING'}); # let's not make the search case-sensitive, ok? $ucsearch = uc($search); $the_file = "./search.txt"; $started_table = "no"; print "Content-type: text/html\n\n"; print ""; print "Search Results"; if ($search ne "") { print "Search Results for $search
"; if (open(THE_FILE, "$the_file")) { # begin the table while () { $record = $_; $_ = uc($_); if (/$ucsearch/) { if ($started_table eq "no") { $started_table = "yes"; print ""; } # begin one table row print ""; @fields = split(/\t/,$record); foreach $field (@fields) { # display one data cell for the table row print ""; } # end of one table row print ""; } } close(THE_FILE); # end of the table if ($started_table eq "yes") { print "
$field
"; } else { print "what you were looking for could not be found.\n"; } print "

"; } else { print "unable to open the file $the_file.\n"; } } else { print "No query string given"; } print "";