Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: pattern matching and array comparison

by Paladin (Vicar)
on Jun 13, 2005 at 20:21 UTC ( [id://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.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-20 16:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found