#!/user/bin/perl -w BEGIN { $|=1; print "Content-type: text/html\n\n"; use CGI::Carp('fatalsToBrowser'); } use Fcntl; # find the keyword in gutenberg.txt #@gut_results; @gutenbergr = (1..56522); array_shuffle (\@gutenbergr); $filename = 'gutenberg.txt'; open (GUT, "< /home/sid/kwicionary/$filename") or die "Can't open $filename for reading: $!"; $path = "/home/sid/kwicionary/"; $indexname = "$filename.index"; sysopen(IDX,$indexname, O_CREAT|O_RDWR) or die "Can't open $indexname for read/write:$!"; build_index(*GUT, *IDX) if -z $indexname; $key = $FORM{'search'}; GUT:foreach (@gutenbergr){ print "$#gut_results \n"; $limit = 100; $line_number = $_; $line = line_with_index(*GUT,*IDX,$line_number); if ($key =~ /\*/){ # $key = substr($key,0,(length($key) -1)); @word = split(' ',$line); foreach (@word){ if ($_ =~ /$key/){ push (@gut_results , $_); if ($#gut_results == 100){last GUT;} } } } else { @word = split(' ',$line); foreach (@word){ if ($_ =~ /^$key$/){ push (@gut_results , $_); if ($#gut_results == 100){last GUT;} #print "matched gutenberg '$_' \n"; } } } undef @word; if ($#gut_results eq $limit){last GUT;} } undef @gutenbergr; #### Premature end of script headers: search.cgi (2)No such file or directory: exec of '/var/www/cgi-bin/authenticate/search.cgi' failed