I need to know how to read from 2 tab-delimited flat files with the while statement. The code I have below only reads from the first one, when I change it to SIDX2 it only reads from the second. I need both files to open and hold them in separate array lists.
And here I need an additional result line like $premiumresultline = $premiumline without the $icnt counter
Code:
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 lock for file: $data_dir/search.idx, $data_dir/search2.idx $!\n";}
while (defined($line=<SIDX>) and ($premiumline=<SIDX2>))
{
$sline = $line, $premiumline;
foreach $kwr (@skeyw, @premiumkeyw)
{
if (($sline =~ /$kwr/i) and ($kwr ne ""))
{
$toadk = "true";
}
}
if ($toadk eq "true")
{
Code:
$resultline[$icnt] = $line;
$toadk = false;
$icnt++;
}
}
#if ($file_locking ne "No"){flock (CIT, LOCK_UN);}
close (SIDX);
close (SIDX2);
}