Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 musing on the Monastery: (4)
As of 2014-09-17 01:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (55 votes), past polls