I have been successful n reading from 2 files and storing contents in an array but now I need to be able to extract the keywords from the array - @skeyw - that has the combined contents of 2 files <SIDX> and <SIDX2>, and split them into 2 separate returns, one return from the keywords found in <SIDX> and the other keywords found in <SIDX2>. They will be inserted into the html placeholders %%searchresults%% and the other in %%premiumresults%%:
$main_template =~ s/%%keywords%%/$fields{'keywords'}/g;
$main_template =~ s/%%searcresults%%/$pitem/g;
$main_template =~ s/%%keywords%%/$fields{'keywords'}/g;
$main_template =~ s/%%premiumresults%%/$pitem/g;
print "Content-type: text/html\n\n";
$main_template = tseek::insert_tmpl_includes($main_template);
print "$main_template";
exit;
Here is where I do the search:
sub normal_search
{
### PERFORM SEARCH
$search_line = $fields{'keywords'};
$icnt = 0;
$toadk = "";
(@skeyw) = split(/ /,$search_line);
$nrkeywords = 0;
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 = "${line2}${line3}";
foreach $kwr (@skeyw)
{
if (($sline =~ /$kwr/i) and ($kwr ne ""))
{
$toadk = "true";
}
}
if ($toadk eq "true")
{
$resultline[$icnt] = "${line2}";
$premium_resultline[$icnt] = "${line3}";
$toadk = false;
$icnt++;
}
}
#if ($file_locking ne "No"){flock (CIT, LOCK_UN);}
close (SIDX);
close (SIDX2);
}
and here is where I need to split the keyword search results from both files that are still contained in @skeyw. Search results from <SIDX> assigned to ($search_line) = @_;
and the search results from <SIDX2> assigned to ($premium_search_line) = @_;
sub get_search_ready
{
my ($search_line) = @_;
$reline = $search_line;
$reline =~ s/[+\[\]()*^.\$?\\~<>;]//g;
return ($reline);
}
sub get_search_ready2
{
my ($premium_search_line) = ${line2};
$premium_reline = $premium_search_line;
$premium_reline =~ s/[+\[\]()*^.\$?\\~<>;]//g;
return ($premium_reline);
}