Skip to main content.
home | support | download

Back to List Archive

Re: Q: Swish-E foreign language character support

From: Bill Moseley <moseley(at)not-real.hank.org>
Date: Mon Feb 05 2001 - 03:59:23 GMT
At 04:41 PM 02/04/01 -0800, Kati Gäbler wrote:
>On Sunday 04 February 2001 11:57, Rainer.Scherg@rexroth.de wrote:
>Only one more detail; I would like some advise on how to include a meta 
>description of the page in the search results. Currently, this is what the 
>result page would look like when using the CGI script as it came:

This isn't the help you are looking for, but this script is really not fit
for use as a CGI script, and I would avoid using it unless you are running
on an closed network where you trust everyone.  The pipe open is insecure,
and looks like it's written for Perl 4.

There are some better scripts on the SWISH-E web site, I believe, but I
haven't looked at them for some time.  Take a look at lookup.cgi -- I
haven't really looked at any of the others (but I would not recommend
swish-cgi.pl due to the same pipe open problem).

Also, take a look at SWISH and SWISH::Fork on CPAN. 
http://search.cpan.org/doc/HANK/SWISH-0.04/SWISH.pm
http://search.cpan.org/doc/HANK/SWISH-Fork-0.08/Fork.pm

If that's an interface you can work with let me know and I'll get updated
versions put up on CPAN (that version has a bug in the timeout feature, and
the interface to the swish headers and properties has been redesigned to
work with features of SWISH-E 2.2.  But if you are not a perl programmer
then that might be more work to get up and running.

To answer your question, use the -d switch to specify a delimiter in your
results, and then split on that:

So (untested and not recommend!)

Instead of this:
  open(SWISH, "$command|");
do

  # WARNING insecure
  open( SWISH, "$command -d :: -p $property_name|")
	or die "Failed to open swish";

And then instead of all this mess:

  elsif (/^[0-9]/) {
    chop;
    # can't simply split because spaces can exit in title
    $firstspace = index("$_", "\ ", 0); 
    if ($firstspace == -1) {
      next;
    }
    $secondspace = index("$_", "\ ", ($firstspace+1)); 
    if ($secondspace == -1) {
      next;
    }
    $lastspace = rindex("$_", "\ ");
    if ($lastspace == -1) {
      next;
    }
    $rank = substr($_, 0, $firstspace);
    $url = substr($_, ($firstspace+1), ($secondspace-$firstspace-1));
    $title = substr($_, ($secondspace+1), ($lastspace-$secondspace-1));
    $numbytes = substr($_, ($lastspace+1));
    print "$rank <a href=\"$url\">$title</a> ($numbytes bytes)<br>\n";
  }
}

Do something like this:

  elsif (/^[0-9]/) {
      chomp;  # this could be right below the while()

      my ( $rank, $url, $title, $numbytes, $property ) = split /::/;

      print qq[$rank <a href="$url">$title</a> ($numbytes bytes)<br>],
            "<blockquote>$property</blockquote>";
  }
            
Again, untested and not advised.



Bill Moseley
mailto:moseley@hank.org
Received on Mon Feb 5 04:03:08 2001