I’m using Perl for the first time (with TextWrangler), and need help with regex!
I have a large string of species names, DNA, and other text. I want to extract the following:
Homo sapiens
Pongo abelii
Macaca mulatta
Right now, I’ve defined $string and have this command (sorry if I’m not using the correct terminology, I’m a total newbie):
while($string =~ m/(Homo sapiens|Pongo abelii|Macaca mulatta)/g)
{
print "$1\n";
}
This is the output I get:
Homo sapiens
Homo sapiens
Pongo abelii
Macaca mulatta
Homo sapiens
Homo sapiens
Homo sapiens
Homo sapiens
Homo sapiens
Homo sapiens
How do I get just ONE of each species name? This has been driving me crazy!!!
Basically, you want to remove duplicates, so use the standard code to do so.