Dente has asked for the wisdom of the Perl Monks concerning the following question:
Here is where I do the search:$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;
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 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); }
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); }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Array extraction and separate returns
by xorl (Deacon) on May 25, 2004 at 15:39 UTC | |
by Dente (Acolyte) on May 26, 2004 at 23:58 UTC |