in reply to
Re^3: Reading two text files parallelly...
in thread Reading two text files parallelly...
Sounds like the main problem is to get very clear about what you want this program to do. If you want to just stop when both files are over, or when lines run out of one of them, another possibility is below. The while() takes an expression that evaluates to true/false. Nothing wrong with have more than one condition in an "and" statement. You can use "or" if you want. I don't see the need for anything fancy - try to keep it as easy to understand as possible.
open (my $fh1, '<', "testa.txt") or die "cannot open testa";
open (my $fh2, '<', "testb.txt") or die "cannot open testb";
while ( defined (my $test1 = <$fh1>) and
defined (my $test2 = <$fh2>)
print "both defined\n";