in reply to pattern matching and array comparison
Well, first off, you should probably always use strict and warnings. use strict would have found your error for you. Well, 1 of the errors.
- In your final for() loop, you are using an array called @sequence which you never initialize anywhere else. I presume you meant to use @gene there instead.
- Your $ids have regex meta chars in them (the |), so you need to tell Perl to treat them as normal characters.
it seems to work.for (my $i=0; $i<@genes; $i++) { foreach my $id (@uniq) { if ($genes[$i] =~ /^\Q$id/) { print "$id\n"; } } }
In Section
Seekers of Perl Wisdom