[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] CGI Script Migration Problem



I am using the standard Search::Dict module in a cgi script to 
perform searches of a biblical dictionary with about 3700 entries. 
The short version is that it works perfectly, albeit slowly, when run 
on a Mac with Netpresenz, but is missing some entries that I know are 
there when run on a Solaris box under Apache. The problem is that 
certain multi-word entries are being missed altho the encoding and 
decoding of the query string appears to be correct. I can't seem to 
get it to see entries like "John the Baptist" altho it finds stuff 
like "Galilee, Sea of." There are some slight differences between the 
Dict.pm on the Solaris box and the one included with MacPerl and I 
thought that might be it, but I installed the Solaris version on my 
Mac and didn't have a problem.

When the search fails, the search term is printed and it looks like 
it's supposed to (i.e., it's not getting munged up). It doesn't 
appear that anything bad happened to the copy of the text file that 
is being searched on the Solaris machine and with single word entries 
or multi-word entries that contain commas, it works fine. The script 
is below and I would be really grateful to anyone who can suggest 
what's going on here. Thanks.

#!/usr/bin/perl -w

# Use or Require statements:
use CGI;
use Search::Dict;

######
# Declare variables:
my($cgi) = new CGI;
$key = $cgi->param('term');
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$file = "/home/sbl-home/EPubs/d/dictionary.txt";

######
# Begin program:

open F, $file     or  die "$0, opening $file to read: $!";
  look(*F, $key, 1, 1) == -1 and die "$0, can't look: $!";
  $_ = <F>;			# read that one line
  close F;
print $cgi->header();
print (qq/<!DOCTYPE HTML PUBLIC "-\/\/IETF\/\/DTD HTML\/\/EN">\n/);
print (qq/<HTML><HEAD><TITLE>$key<\/TITLE><\/HEAD><BODY>\n/);

  if (defined and /^$key\b/i) {
				s/(^.+)\|(.+)/<B>$1<\/B>$2/;

    print;
    }
    else                       {print "$key not found.\n"}
print $cgi->end_html();
######

Richard Gordon
--------------------
Gordon Consulting & Design
Database Design/Scripting Languages
mailto://maccgi@bellsouth.net
770.565.8267

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org