#!/usr/local/bin/perl ######################################################################### # search2: Search for ice cream orders - multiple search fields ######################################################################### use CGI "param"; $searchName = param('fullname'); $searchAddr = param('addr'); $searchFlavor = param('ice'); print "Content-type: text/html \n"; print "\n"; open (ORDERFILE, "< ../../data/order.file") || print "Cannot open file - $!"; print " Search for orders

Result for search:

"; while($rec = ) { chomp($rec); ($fname,$address,$flavor) = split(/:/,$rec); $address =~ s/__/
/g; if ((! $searchName or $fname =~ /$searchName/i) and (! $searchAddr or $address =~ /$searchAddr/i) and (! $searchFlavor or $flavor eq $searchFlavor)) { print "
\n"; } } print "
Name Address Ice Cream Flavor
$fname $address $flavor
"; exit(0);