import-bot (20211) [Avatar] Offline
#1
[Originally posted by graham patterson]

Hi Andrew,

I was playing around with the CGI version of faqgrep in chapter 14, and having
got it to work (under Apache on Linux), I just wanted to ask your opinion on a
small problem I encountered, in case any other readers have the same trouble.

I didn't have any HTML docs on my system, so I converted the POD files using
pod2html. However, when I ran the program, the "sort by relevance" Schwartzian
transform didn't seem to be working, ie, the results appeared to be in the
order they were found in the FAQs, and not with the most relevant hits at the
top.

After some head-scratching, I peeked at the HTML and noticed that the $result
string contained no newlines -- which is presumably why the Schwartzian
transform wasn't working, because it couldn't split the string on non-existent
newlines. So I just added an
in the grep_faq_heads sub like this (p252):

$result .= qq|
  • $score $what
    |; #
    added

    and magically, the results appeared correctly sorted. From the above, does it
    sound like I have understood the Schwartzian transform correctly -- or can you
    spot any flaw in my reasoning and solution?

    Thanks as always for your expert help,
    Graham