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]; } } }
In reply to for loop trouble by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |