A B C #### 1 5 10 #### A BBBBB CCCCCCCCCC #### # Open both input files open A, "<$file_a" or die "Unable to open $file_a: $!\n"; open B, "<$file_b" or die "Unable to open $file_b: $!\n"; # Process the files parallel while (1) { # Read the lines my $a = ; my $b = ; # Good coders would check and warn if one entry was defined and the other # was not, but this is just an example, so you should be happy you even # get comments. last if !defined $a || !defined $b; # Process the output print data_transform($a, $b); } close A; close B;