A Web-Search CGI
By Randal L. Schwartz
A common question in the WWW newsgroups is, How do I make my Web pages searchable? Many fancy packages are available to WAIS-index, GLIMPSE-index, or "excite" your Web server, but what if you just want to make a dozen or so scripts (say, from past Web Techniques columns) available and searchable? I encountered this problem the other day when someone asked me which one of my columns talked about flock(). I couldn't recall, so I solved the problem with a script (talk about overkill).
The idea for this script came in part from a similar script written by my associate Joseph Hall (joseph@5sigma.com) as part of our CGI-course training materials. However, Joseph's script didn't make all the matched characters bold, so I planned to add this feature with just a few lines of code. Unfortunately, in the process I discovered a bug in Perl that won't be fixed until version 5.004, so my workaround took a few more lines than I originally planned.
Walking Through
The resulting Web-search CGI program can be seen in
Listing One. Line 1 starts most of the programs I write these days, enabling "taint" mode with -T to prevent outside data from unknowingly being used to my disadvantage) and -w to tell me what I've done stupidly.