档案1.txt
hello
tom
well
档案2.txt
world
jerry
done
How to merge 档案1.txt with 档案2.txt; then create a new file - file3.txt
hello world
tom jerry
well done
感谢你阅读和答复。
附上基于答案的完成守则。
#!/usr/bin/perl
use strict;
use warnings;
open(F1,"<","1.txt") or die "Cannot open file1:$!
";
open(F2,"<","2.txt") or die "Cannot open file2:$!
";
open (MYFILE, >>3.txt );
while(<F1>){
chomp;
chomp(my $f2=<F2>);
print MYFILE $_ . $f2 ."
";
}