I have successfully been able to assign separate filehandles to scalers, search and return results, however, both file search results return in both placeholders. I need to assign a $line3 to $main_template =~ s %%searcresults%%/$pitem/g; and $line2 to $main_template =~ s %%premiumresults%%/$premiumitem/g;
$main_template =~ s/%%keywords%%/$fields{'keywords'}/g; $main_template =~ s/%%searcresults%%/$pitem/g; $main_template =~ s/%%premiumresults%%/$premiumitem/g;
$pitem and $premiumitem only represent the HTML file insertion names and are not relevant here. I am thinking I need an if, elsif and else statement somewhere so that $main_template =~ s/%%searcresults%%/$pitem/g; is assgned with $line3 if the results are found in SIDX, that $main_template =~ s/%%premiumresults%%/$premiumitem/g; is assigned with $line2 if the results are found in SIDX2, and that both are returned if the results were found in both SIDX and SIDX2.
foreach $item (@skeyw){$nrkeywords++;} open (SIDX, "$data_dir/search.idx"); open (SIDX2, "$data_dir/search2.idx"); if ($file_locking ne "No"){flock (SIDX, LOCK_SH) or die "Can't set lo +ck 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}"; $toadk = false; $icnt++; } } #if ($file_locking ne "No"){flock (CIT, LOCK_UN);} close (SIDX); close (SIDX2); } $main_template = html::insert_tmpl_includes($main_template); print "$main_template"; exit;

In reply to Assigning scalars to scalar template includes by Dente

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.