Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (16)
As of 2014-12-18 12:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (51 votes), past polls