I seek wisdom in regards to referencing an assigned scaler variable - $search_line = $fields{'keywords'}; and a 2nd scaler variable which performs the same funtion - $search_line2 = $fields{'keywords'};. The 2nd variable must not eliminate the value of the first, but include the same assignment from a different file. Initially, I need to separate the return results of search_line and search_line2. The initial assignment opens 2 files (by design) Assignment:
foreach $item (@resultline, @premium_resultline)
open (SIDX, "$data_dir/search.idx"); open (SIDX2, "$data_dir/search2.idx");
then pulls in 2/both files for reading/search simultaneously:
(@skeyw) = split(/ /,$search_line);
if ($file_locking ne "No"){flock (SIDX, LOCK_SH) or die "Can't set loc +k for file: $data_dir/search.idx, $data_dir/search2.idx $!\n";} while($line3 = <SIDX>) { $line2 = <SIDX2>; $sline = "${line1}${line2}${line3}"; foreach $kwr (@skeyw) { if (($sline =~ /$kwr/i) and ($kwr ne "")) { $toadk = "true"; } } if ($toadk eq "true") { $premium_resultline[$icnt] = "${line2}"; $resultline[$icnt] = "${line3}"; # $resultline[$icnt] = "${line1}${line2}${line3}"; $toadk = false; $icnt++; } } #if ($file_locking ne "No"){flock (CIT, LOCK_UN);} close (SIDX); close (SIDX2); }
I am thinking this for logic reasons: $search_line = $fields{'keywords'}; $search_line2 = $fields{'keywords'};
(@skeyw) = split(/ /,$search_line); (@skeyw) = split(/ /,$search_line2);
However this does not allow for logic since I need the @skeyw to split itself once yet recognize that SIDX and SIDX2 are separate files. The search result return is:
sub get_search_ready { my ($search_line) = @_; my ($search_line2) = @premium_resultline; $reline = $search_line; $reline = $search_line2; $reline =~ s/[+\[\]()*^.\$?\\~<>;]//g; return ($reline); }

In reply to Separating multiple keyword search input by Anonymous Monk

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.