Entering edit mode
12.0 years ago
bioinformatics123
▴
10
Perl newbie here: How can one input one file and compare it with two separate files(file 1 and file2) line by line for comparison in perl? After I input my main file then something like the code below may read two files but it isn't working for me..
open (MYFILE1, "test.txt");
@file1=<MYFILE>;
close MYFILE1;
open (MYFILE2, "test2.txt");
@file2=<MYFILE2>;
close MYFILE2;
foreach $line (@file1) {
foreach (@file2) {
if ($_ =~ /$line/) {
print $line;
}
}
}
is this okay?