#!/usr/bin/perl -Tw #----------------------------------------------- # # Purpose: To demonstrate a simple script to # process the search query for a quotations # search system # # Author: H.L. Hiew # Created: 10/07/2000 # Last modified: 12/08/2001 # #----------------------------------------------- use CGI qw(:standard) ; # get the user-supplied query name my $quoter = param("qname") ; # print the opening of the results page print < Search Results

Search Results


END_HTMLStart # open the quotations file for reading open(QUOTESFILE, ") { chomp $line ; ($name, $quote) = split(/;/,$line) ; if ($name =~ /$quoter/i) { print "

$name said, $quote<\/p>" ; # Tip: we have to escape the "/" by using "\/" because "/" has # special meaning in Perl. } } close(QUOTESFILE) ; print < END_HTMLEnd