SCRUFFYbEAR
IS-IT--Management
Hi,
on a web page a user fills in two fields hits the button and gets a value returned.
in the script the values returned are validated and joined to make the search query - this works okay :-o)
the flat file has two fields per record seperated by a | the first field is the unique identifier the second is the value - when the search occurs it does not find any results even though there is a definite match in the base.
the following is the piece of code that fails, it always prints out the fail part!!
anybody help?
TIA
terry
on a web page a user fills in two fields hits the button and gets a value returned.
in the script the values returned are validated and joined to make the search query - this works okay :-o)
the flat file has two fields per record seperated by a | the first field is the unique identifier the second is the value - when the search occurs it does not find any results even though there is a definite match in the base.
the following is the piece of code that fails, it always prints out the fail part!!
Code:
####You have the search string - now search####
open (FILE, "$database");
while (<FILE>) { # range over address file
%rec = &read_addr();
if (%rec) { # got a record
&perform_search($search, %rec);
} else { # end of address file, finish up
print "Content-type: text/html\n\n";
print "<html><head><title>Thank you!</title></head>\n";
print "<BODY><h1>Thank you!</h1><br>Thanks for your input! \n";
print "width....$width\n";
print "height....$height\n";
print "style....$style\n";
print "search....$search\n";
print "record....$curr\n";
print "not in here. \n";
if (!$bigmatch) {
&print_error();
} else { print "*********************\n"; }
last; # exit, we're done
}
}
# read an item from the file, split it into
# values, and store those values in a hash. Return that hash.
sub read_addr {
my %curr = (); # current record
my $key = ''; # temp key
my $val = ''; # temp value
while (<>) { # stop if we get to EOF
chomp;
if ($_ ne '---') { # record seperator
($key, $val) = split(/|/,$_,2);
$curr{$key} = $val;
}
else { last; }
}
return %curr;
}
TIA
terry