I have two text files, one of which is a list of names and the other is the "main" file. What I am trying to do is read both files into arrays to that I can identify lines in the "main" file that contain any of the names in my list, and then return those lines from the main file.
For example, one name is "pectinesterase". One line in the "main" text file is:
<species id="pectinesterase" compartment="default">
so I'd need to return the whole line.
so far I have:
but that's not giving exactly the result i'm after... any hints would be brilliant thanks
For example, one name is "pectinesterase". One line in the "main" text file is:
<species id="pectinesterase" compartment="default">
so I'd need to return the whole line.
so far I have:
Code:
my @names = <NAMES>;
my @source = <MAIN>;
foreach my $source(@source) {
foreach my $name(@names) {
if ($source =~ $name) {
print OUTFILE $source . "\n";
}
}
}
but that's not giving exactly the result i'm after... any hints would be brilliant thanks