&readbksic(); &readbkprm(); $pss = "$in{'productsearch'}"; &productsearchbymodel($pss); &productsearchbydesc($pss); @matchlist = (@modelmatches,@descmatches); my @matches = keys %{ { map {$_=>1 } @matchlist} }; &DisplayHTML('/usr/local/apache/post/invorder.pl/screens/display_products_top.html'); foreach $linenumber (@matches){ $VCD = $BKSIC_MFG[$linenumber]; $VMN = $BKSIC_MODEL[$linenumber]; $VPD = $BKSIC_DESC[$linenumber]; $QOH = $BKSIC_QOH[$linenumber]; &DisplayHTMLOnly('/usr/local/apache/post/invorder.pl/screens/display_products_middle.html'); } &DisplayHTMLOnly('/usr/local/apache/post/invorder.pl/screens/display_products_bottom.html'); exit; } } sub productsearchbymodel { my $modelterms = shift; my $modelpattern = join "|", split " ", $modelterms; my $modelcase = $in{'case'} eq 'insensitive'?"(?i)":""; $modelpattern = qr/$modelcase$modelpattern/; # my @modelmatches = grep { /$modelpattern/ } @BKSIC_MODEL; #This will store the actual matching string my @modelmatches = grep { $BKSIC_MODEL[$_] =~ /$modelpattern/ } 0..$#BKSIC_MODEL; #This will store the index ID of the matching array element. return @modelmatches; } sub productsearchbydesc { my $descterms = shift; my $descpattern = join "|", split " ", $descterms; my $desccase = $in{'case'} eq 'insensitive'?"(?i)":""; $descpattern = qr/$case$pattern/; # my @descmatches = grep { /$descpattern/ } @BKSIC_DESC; #This will store the actual matching string my @descmatches = grep { $BKSIC_DESC[$_] =~ /$descpattern/ } 0..$#BKSIC_DESC; #This will store the index ID of the matching array element. return @descmatches; }