I don't know if this will help or not but this is my approach assuming the files are relatively small in size and that the lines in each file are equal to each other
#!/usr/bin/perl
use warnings;
use strict;
open my $a, "<", "file1.txt" or die "Failed to open File : $!";
open my $b, "<", "file2.txt" or die "Failed to open File : $!";
open my $out, ">", "output.txt" or die "Failed to open File : $!";
chomp(my @file1=<$a>);
chomp(my @file2=<$b>);
close $a;
close $b;
my $max = @file1;
my $min = 0;
while ($min < $max) {
print $min."\n";
print $out "$file1[$min] : $file2[$min]\n";
$min++;
}
close $out;
Of course with the print $out statement you can use any separator you chose (chose a colon). Hope it helps