Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: pattern matching and array comparison

by Paladin (Priest)
on Jun 13, 2005 at 20:21 UTC ( #466283=note: print w/ replies, xml ) Need Help??

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.

Comment on Re: pattern matching and array comparison
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://466283]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2015-11-27 09:33 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (722 votes), past polls