note
LanX
<c>
my ($a,$b);
while( $a=<F1>, $b= <F2>, $a or $b) {
...
}
</c><P><P>
reads till the end of the longer file. Changing to <C>and</C> limits to shorter one.
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-708738">
<p>Cheers Rolf
<p> <small>( addicted to the Perl Programming Language) </small>
</div></div><P><P>
<H5> UPDATE Please note<P></H5><P>
Since $a and $b are not chomped, no normal input line should ever be false and hence not necessarily tested with <C>defined</C>. <P><P>
Better take care if you are using special filehandles allowed to return a simple 0 or null strings!!!<P><P>
<H5> UPDATE<P></H5><P>
safer:<P><P>
<c>
use strict;
use warnings;
use Data::Dump qw/pp/;
open my $f1, "<", \ join "\n", 1..2;
open my $f2, "<", \ join "\n", 1..5;
while( defined (my $a=<$f1>) + defined (my $b=<$f2>) ) {
$a .="";
$b .="";
chomp($a,$b);
print "$a,$b\n";
}
</c>
out
<c>
1,1
2,2
,3
,4
,5
</c>
<P><P>
In boolean context: <c>+</c> is like <C>or</C>, <c>*</c> is like <C>and</C>, just w/o short circuit.
1031722
1031722