I have read the Q&A section pertaining to arrays, however this example is slightly beyond the scope of the topics discussed.

I need to search 2 flat text files and return the search results in 2 separate columns. 1 column for international, and the other local listings. This search needs to open both files, read them, and return results. The HTML template I am using pulls search_line into a single column via %%searchresults%% . I have added a second include %%premiumlistings%% column adjacent to it. I know I need to assign each file to an array and then use the split / / function, but I seem to run into a problem using the while statement. The script is as follow:

Earlier in script:

<CODE>

$main_template =~ s/%%keywords%%/$fields{'keywords'}/g;
$main_template =~ s/%%searcresults%%/$pitem/g;

</CODE>

returns results in left column via %%searchresults%%

<CODE>

$main_template =~ s/%%keywords%%/$fields{'keywords'}/g;
$main_template =~ s/%%premiumlistings%%/$premiumitem/g;

</CODE>

returns SAME results in right column via %%premiumresults%%


This is where the problem starts:

<CODE>

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");

#################
### added 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";}

## here's 1st problem (only opening and reading 1st file ##
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);

}

## 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:

###############

$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;

}

## and finally:

sub get_search_ready
{
my ($search_line) = @_;

$reline = $search_line;

$reline =~ s/\+//g;
$reline =~ s/\[//g;
$reline =~ s/\]//g;
$reline =~ s/\)//g;
$reline =~ s/\(//g;
$reline =~ s/\*//g;
$reline =~ s/\^//g;
#$reline =~ s/\.//g;
$reline =~ s/\$//g;
$reline =~ s/\?//g;
$reline =~ s/\\//g;
$reline =~ s/\~//g;
$reline =~ s/<//g;
$reline =~ s/>//g;
$reline =~ s/;//g;

return ($reline);
}

</CODE>