http://qs321.pair.com?node_id=1075417


in reply to Re: Use 2 files and print each line of each one side-by-side
in thread Use 2 files and print each line of each one side-by-side

Also for fun, a Perl 6 version.
Note that this only works for files of the same length, because Z terminates (without error) when the shorter list ends.

use v6; sub MAIN ( $in_path1, $in_path2, $out_path = 'CONCATENATED_FILES' ) { my $in1 = open $in_path1, :r; my $in2 = open $in_path2, :r; my $out = open $out_path, :w; for $in1.lines Z $in2.lines -> $line1, $line2 { $out.say: "$line1\t$line2"; } .close for $out, $in1, $in2; }