Dente has asked for the wisdom of the Perl Monks concerning the following question:
$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.$main_template =~ s/%%keywords%%/$fields{'keywords'}/g; $main_template =~ s/%%searcresults%%/$pitem/g; $main_template =~ s/%%premiumresults%%/$premiumitem/g;
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Assigning scalars to scalar template includes
by dws (Chancellor) on Jun 30, 2004 at 06:41 UTC | |
by Dente (Acolyte) on Jul 01, 2004 at 10:56 UTC | |
by dws (Chancellor) on Jul 01, 2004 at 19:18 UTC |