#!/usr/local/bin/perl
@fields = (‘Contact’,’Religous/Secular’,’Concern’,’Agency Name’,’Primary Address’,’Address 2′,’City’,’State’,’Zip’,’HOURS’,’Phone’,’800-Phone’,’Fax’,’2Address’,’2Address2′,’2City’,’2State’,’2Zip’,’Service Area’,’written info on request’,’counselling referrals’,’Crisis Intervention’,’Professional Group’,’Support Group’,’Newsletter Fqy’,’COMMENTS’);
$view_fields = “‘Contact’,’Religous/Secular’,’Concern’,’Agency Name’,’Primary Address’,’Address 2′,’City’,’State’,’Zip’,’HOURS’,’Phone’,’800-Phone’,’Fax’,’Service Area’,’written info on request’,’counselling referrals’,’Crisis Intervention’,’Professional Group’,’Support Group’,’Newsletter Fqy’,’COMMENTS'”;
$data_file = ‘/usr/local/etc/httpd/save-data/save5.txt’;
print “Content-type: text/htmlnn”;
print “n”;
print “
SAVE Simple Text Search Results
n”;
&parse_form;
&read_file;
if (!(&return_results)) {
&print_sorry;
}
print “n”;
1;
sub print_sorry {
print “
Sorry, there were no matches to your search.
n”;
print “Please try again.
n”;
print “
n”;
}
sub read_file {
open (IN, “<$data_file");
@lines =
close (IN);
}
sub return_results {
local(@include);
local(@data);
local($line) = ”;
local($include) = ”;
if ($FORM{‘refine’}) {
$FORM{‘search’} .= ” $FORM{‘refine’}”;
}
local(@search_terms) = split (/s/,$FORM{‘search’});
print “Search Terms:
"; foreach $s (@search_terms) { print "t$s"; } print "
n”;
foreach $line (@lines) {
$include = ‘yes’;
foreach $s (@search_terms) {
if ($line !~ /$s/i) { $include = ‘no’; }
}
if ($include eq ‘yes’) {
unshift (@include, $line);
}
}
if (@include) {
print “