http://qs321.pair.com?node_id=466283


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.
  1. 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.
  2. Your $ids have regex meta chars in them (the |), so you need to tell Perl to treat them as normal characters.
If you change your final part to:
for (my $i=0; $i<@genes; $i++) { foreach my $id (@uniq) { if ($genes[$i] =~ /^\Q$id/) { print "$id\n"; } } }
it seems to work.