in reply to Printing Columns from Two Different Files

If you are processing the three files (two input, one output) really line by line, then one while loop is enough. Just open all three files beforehand and close them afterwards. Something like the following code should work then:
my $folder1 = 'folder1' my $folder2 = 'folder2'; my $folder_out = 'outfolder'; my $textfile = 'file.txt'; open(my $file1, "< $folder1/$textfile") or die $!; open(my $file2, "< $folder2/$textfile") or die $!; open(my $outfile, "> $folder_out/$textfile") or die $!; while (my $line1 = <$file1> ) { my $line2 = <$file2>; my @data1 = split, $line1; my @data2 = split, $line2; print $outfile @data1[1..7], $data2[3], "\n"; } close($file1); close($file2); close($outfile);

-- Hofmator