#!/usr/local/bin/perl -Tw # search.cgi - a simple search cgi script # # modified by Gordon Ross (gordonr@cs.sfu.ca) (22/04/97) # original code by Brian Slesinksy (bslesins@hotwired.com) require 5.001; # use strict; use DB_File; # perl 5 lib not installed on CSSnet, AnyDBM_File.pm is though. # use AnyDBM_File; # POD stuff =head1 NAME search.cgi - search page for a Web site =head1 DESCRIPTION See my article in Webmonkey for a complete description: http://www.webmonkey.com/code/97/16/index2a.html =head1 AUTHOR Brian Slesinsky =cut # parse form data my $query = $ENV{'QUERY_STRING'}; $query =~ s/q=//; $query =~ s/%[0-9a-fA-F]{2}/ /g; my @words = ($query =~ /\w+/g); # print search form my $query_value = join(' ',@words); # my $titlestring = "Search"; if ($query eq "") { $titlestring = "Search"; } else { $titlestring = "Results for $query"; } # beginning of HTML (header and just before the for loop) print <<_HTML; Content-type: text/html\n\n $titlestring
the peak
b e t a - s e a r ch


this is the somewhat experimental search engine for the e.peak
you are currently searching the 1997 spring semester.


_HTML if($query eq "") { print <<_HTML;


back to the peak

_HTML } else { print "Results : (date -- section: title)
\n

back to the peak

_HTML } __END__ # ...and here's the three-line version # !/usr/local/bin/perl -- part 2: save as find.cgi in your_web_dir -bslesins # use DB_File;$_=$ENV{'QUERY_STRING'};s/s=//;$p="value=$_>";if($_){dbmopen(%w, # db,0);tr[A-Z][a-z];$_=$w{$_};for(sort/-\d+/g){$p.="

"; # }}print"Content-type: text/html\n\n