file1.txt
hello
tom
well
file2.txt
world
jerry
done
How to merge file1.txt with file2.txt; then create a new file - file3.txt
hello world
tom jerry
well done
thank you for reading and reply.
Attached the completed code.
#!/usr/bin/perl
use strict;
use warnings;
open(F1,"<","1.txt") or die "Cannot open file1:$!\n";
open(F2,"<","2.txt") or die "Cannot open file2:$!\n";
open (MYFILE, '>>3.txt');
while(<F1>){
chomp;
chomp(my $f2=<F2>);
print MYFILE $_ . $f2 ."\n";
}