There's a problem in the loop that removes items according to a regex. Whenever an item is removed, the items to the right are shifted over, but
$i is still incremented. See:
my @arr = qw/ foo foozle bar bar2 foo bar foo /;
for (my $i=0; $i<@arr; $i++) {
splice(@arr, $i, 1) if ($arr[$i] =~ /bar/);
}
print "$_\n" for (@arr);
## output: bar2 is NOT removed
It will fail to check the next item after each match. It's much simpler (and correct-er) to write:
@chroms = grep { ! /[pqxy]/i } @chroms;
Although, if you're dealing with a huge amount of genetic data, this will be very slow. A quick fix to the existing loop would be the slight change:
for (my $i=0; $i<@chroms; $i++) {
splice(@chroms, $i--, 1) if not $chroms[$i] =~ /[pqxy]/i;
} ####
This still may not be optimal, but it's in-place so should be faster than the grep.
About your second question... Off the top of my head, I'm not sure what's up with your regex... It's late for me!
blokhead
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.