Skip to main content.
home | support | download

Back to List Archive

search.cgi bug w.r.t. mod_perl?

From: Greg Fenton <greg_fenton(at)>
Date: Tue Jun 01 2004 - 05:53:44 GMT
SWISH-E 2.4.2
mod_perl 1.0
Apache 1.3.27
RH 7.3
Perl 5.6.1

We have built a new mod_perl search script based on the sample code in
search.cgi.  I simply sat on a results page clicking reload in my
browser about 10-15 times and then I got a Server Error.

The error_log indicates:

[Tue Jun  1 00:19:35 2004] [error] undef error - Can't call method
"highlight" on an undefined value at /home/apache/cgi-bin/search line

This code comes straight from search.cgi (though line numbers and
indenting are slightly different):

             sub {
                  my ( $context,  $metaname ) = @_;
                  my $phrases =
                  return sub {
                      my $text = shift;
                      $highlight_object->highlight(\$text,   # <--302
                      return $text;
              },  1 );

After digging around in the mod_perl 1.0 docs, it appears to me that
this is an instance of The First Mystery at:

Changing the declaration of the "cached" variables from:

   my ( ..., $swish, $highlight_object, ...);


   our ( ..., $swish, $highlight_object, ...);

seems to make the problem disappear.  I've made all "my" declarations
in this script "our" instead...though this may not be necessary.

I'd be very happy to hear that I'm wrong on this...or be given a better
solution than the one above.

Hope this helps,

Greg Fenton

Do you Yahoo!?
Friends.  Fun.  Try the all-new Yahoo! Messenger. 
Received on Mon May 31 22:53:45 2004