Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I can't work out what is wrong with my loop. I'm simply iterating through an array called @pids (630 items). I want to get those items that match things in a different array and those that don't seperately.
I get 400 items in @hits as expected but the full 630 items in the @potential_hgt array (when it should be finding 230).
Can someone please advise where i'm going wrong?
cheers
foreach my $orth (@orthologs) { my $hit; if ($orth =~ /^A(\d+)/) { $hit=$1; } + + for (my $i=0; $i<@pids; $i++) { if ($pids[$i] =~ /$hit/) { push @hits, $hit; } else { push @potential_hgt, $pids[$i]; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: for loop trouble
by Corion (Patriarch) on Aug 12, 2005 at 09:59 UTC | |
by fishbot_v2 (Chaplain) on Aug 12, 2005 at 13:00 UTC | |
by Roy Johnson (Monsignor) on Aug 12, 2005 at 15:03 UTC | |
|
Re: for loop trouble
by ambrus (Abbot) on Aug 12, 2005 at 10:01 UTC | |
|
Re: for loop trouble
by graff (Chancellor) on Aug 12, 2005 at 15:23 UTC |