Skip to main content.
home | support | download

Back to List Archive

Re: Getting older .cgi scripts to work with swish-2.1-dev25 ?

From: Andrew Lord <andrewlord(at)not-real.internode.on.net>
Date: Mon Jun 03 2002 - 15:13:01 GMT
Hi Bill,

Thankyou very much for your response.

> There's much easier and faster ways to do that now.  If you want all the
> words that start with a given letter you can use the -k switch.  To show
> all words in the index that start with "c"
>
>     ./swish-e -k c
>
> and split on white space.

I have tried the above (and index_words_only) at the command-line level and 
have had no problems, at that level.  However I've had no luck with changing 
makewordlist() in dictionary.cgi.  

I looked around via Google and attempted a number of hit-and-miss (*very* 
trial & error) changes to makewordlist(), over the past few hours, but none 
so far have brought improvement to dictionary.cgi.  What I have tried is 
shown below (-k has been used in place of -D in makewordlist() for all the 
following variants):

($word, $numbers) = split(/:/,$_);  =>This is the current (original) code and 
produces "err" under the letter 'e'

($word, $numbers) =split(/\s+/,$_);	 => only result is "err:" (not "err") 
from letter 'e' (nothing from any other letter).

($word, $numbers) =split(/:/s+$_); => Nothing at all (not even "err" from 
letter 'e')

($word, $numbers) =split(/:/\s+$_);	 => Internal Server Error.
($word, $numbers) =split(/:/\s+_);	 => Internal Server Error.
($word, $numbers) =split(/:/\s+/$_); => Internal Server Error.
($word, $numbers) =split(/:\s+$_);	 => Internal Server Error.
($word, $numbers) =split(/:/\s$_);	 => Internal Server Error.
($word, $numbers) =split(/:/\s/$_);	 => Internal Server Error.

My lack of progress to date is probably because I am not proficient in perl.  
However, given what is likely to be your comparative wealth of 
experience with perl, chances are that the necessary improvements to 
makewordlist(), which appear to me as ghosts through heavy fog, might shine 
to you as beacons in the night :-)

So I wondered if you (or others on the list) could please suggest some 
scenarios for change to makewordlist() that might see dictionary.cgi 
functioning under swish-e-2.1-dev-25.
  
Cheers,

Andrew

PS.    > You might want to adjust the script to start like:
>
>   #!/usr/local/bin/perl -wT
>   use strict;
>
> That will catch potential errors in the script.

I tried the above in dictionary.cgi and, even while attempting to use the 
then-modified dictionary.cgi with swish-e-2.0.5 (which otherwise works 
perfectly with dictionary.cgi), the error_log showed that it fell over on 
more lines than I know how to count.   So I'm unsure of the value of 'use 
strict;' with this script.  I need to learn about debugging.
_____________________________________________
sub makewordlist{
	$swish = '/usr/local/bin/swish-e';

	open SWISH, '-|' or exec $swish, '-k',"$swishdir/$index" 
		or exec 'echo',"$!";
	while(<SWISH>) {
		next if /^\d/;
		next unless /^$pattern/;
		chop;
		($word,$numbers) = split(/:/,$_);
		if(length $numbers > 0) {
			push @words,$word;
		}
	}
}

______________________________________________
Received on Mon Jun 3 15:16:36 2002