Dente has asked for the wisdom of the Perl Monks concerning the following question:
HTML Template Includes: Simple HTML doc created in GoLive %%searchresults%% %%premiumlistings%% Required is as follows20660 Gekko Gear Selection of winter sports apparel Apparel_a +nd_Accessories-Athletic_Clothing www.gekkogear.com/
The script is as follow:use Fcntl qw(:DEFAULT :flock); use CGI; use CGI::Carp qw(fatalsToBrowser);
returns results in left column via %%searchresults%%$main_template =~ s/%%keywords%%/$fields{'keywords'}/g; $main_template =~ s/%%searcresults%%/$pitem/g;
unfortunatly returns same results in right column via %%premiumresults%%. This is where the problem starts:$main_template =~ s/%%keywords%%/$fields{'keywords'}/g; $main_template =~ s/%%premiumlistings%%/$premiumitem/g;
here's 1st problem (only opening and reading 1st filesub 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"); added code below to open 2nd file open (SIDX2, "$data_dir/search2.idx"); if ($file_locking ne "No"){flock (SIDX, LOCK_SH) or die "Can't set lock for file: $data_dir/search.idx, $data_dir/search2.idx $!\n";}
I need this to open both files and return the results of search.idx in the right column and search2.idx in the right. This is the latter area of importance:while (defined($line=<SIDX>)) { $sline = $line; foreach $kwr (@skeyw) { if (($sline =~ /$kwr/i) and ($kwr ne "")) { $toadk = "true"; } } if ($toadk eq "true") { $resultline[$icnt] = $line; $toadk = false; $icnt++; } } #if ($file_locking ne "No"){flock (CIT, LOCK_UN);} close (SIDX); }
$resultline[$rcc] = $row[0] . "\t" . $row[1] . "\t" . $row[2] . "\t" . $row[3] . "\t" . $row[4] . "\t" . $row[5] . "\t" . $row[6] . "\t" . $row[7] . "\t" . $row[8] . "\t" . $kinclude . "\n"; $rcc++; } $sth->finish; $dbh->disconnect;
janitored by ybiC: Closed final <code> tag, replaced (excessive for viewing) tabs with spaces, balanced <readmore> tags around longish codeblock
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: assigning flat file dbs to arrays
by Zaxo (Archbishop) on Apr 25, 2004 at 22:00 UTC | |
by Dente (Acolyte) on Apr 26, 2004 at 23:24 UTC | |
by jarich (Curate) on Apr 27, 2004 at 06:15 UTC | |
by Dente (Acolyte) on Apr 28, 2004 at 13:34 UTC | |
by Dente (Acolyte) on Apr 28, 2004 at 21:13 UTC | |
by jarich (Curate) on Apr 29, 2004 at 03:22 UTC | |
|