my @files = ("1.txt", "2.txt", "3.txt"); my @fhs; foreach my $file (@files) { open($fh, $file) || die; push(@fhs, $fh); } open(MIXED, "mixed.txt") || die; while (1) { foreach $fh (@fhs) { $line = <$fh>; last if (eof($fh)); print MIXED $line; } } map { close($_); } @fhs; close(MIXED);