Michael Fowler wrote: > > You did, but you don't mention what should happen when one of the input > filehandles reaches EOF before the other, or if that's possible. > > The solution I would use would go something like this: > > while (1) { > my $first_in = <FIRSTIN>; > last unless defined $first_in; > > my $second_in = <SECONDIN>; > last unless defined $second_in; > > print FIRSTOUT "$first_in\n"; > print SECONDOUT "$second_in, $first_in\n"; > } > > The loop stops when EOF is reached in either filehandle; you may want to > stop it only when it's reached in both handles, or in one of the handles > only.
If you want to stop at EOF you should test for EOF. :-) while (1) { my $first_in = <FIRSTIN>; last if eof( FIRSTIN ); my $second_in = <SECONDIN>; last if eof( SECONDIN ); print FIRSTOUT "$first_in\n"; print SECONDOUT "$second_in, $first_in\n"; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]