I am trying to search thru 2 arrays for the same string. Record the matching indexes of both search in the same array of results. Then weed out the duplicate results & process the results. Here is the code I've been trying to use.

&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_produ +cts_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/displ +ay_products_middle.html'); } &DisplayHTMLOnly('/usr/local/apache/post/invorder.pl/screens/displ +ay_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 w +ill store the actual matching string my @modelmatches = grep { $BKSIC_MODEL[$_] =~ /$modelpattern/ } 0. +.$#BKSIC_MODEL; #This will store the index ID of the matching array e +lement. 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 eleme +nt. return @descmatches; }

When I perform only 1 search the code works fine. When I try to perform both, no matches are found.


In reply to Conflicts combining arrays? by akm2

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.