file1::line1
file2::line1
file3::line1
file1::line2
file2::line2
file3::line2
...
####
file1::line12
file2::line12
file3::line12
file1::line1
file2::line1
file3::line1
file1::line1
file2::line1
file3::line1
...
####
#!/usr/bin/perl -w
# These files have this format:
# filename::line number (e.g., 1.txt::1)
my @files = (
"1.txt",
"2.txt",
"3.txt",
);
my $total_strings = 9;
my $cur_pos = 0;
my $next_pos = 0;
open(MIXED, ">mixed.txt") || die "(x) Failed: mixed.txt - $!\n";
for (my $cur_string=1; $cur_string <= $total_strings; $cur_string++) {
print "\nCurrent String: $cur_string of $total_strings\n";
foreach my $file (@files) {
print " Opening File: $file\n";
print " Current Position is: $cur_pos\n";
open(FILE, $file) || die "(x) Failed: $file - $!\n";
while() {
seek(FILE, $cur_pos, 1);
$string = $_;
$next_pos = tell(FILE);
}
close(FILE);
print " Read string: $string";
print MIXED $string;
print " Next Position is: $next_pos\n\n";
}
$cur_pos = $next_pos;
}
close(MIXED);