$promoters_regex[0] = qr/[NT][GCATN][NG][NC][NG][NT][NG]/; $promoters_regex[1] = qr/[NG][NT][NG][NC][NG][GCATN][NT]/; $promoters_regex[2] = qr/[NA][GCATN][NC][NG][NC][NA][NC]/; $promoters_regex[3] = qr/[NC][NA][NC][NG][NC][GCATN][NA]/; ... $permutations_total++ while $string =~ $promoters_regex[$j];
You would also find it a bit faster if you could combine all the regexes into a big alternative regex, but then you couldn't match multiple promoters that overlap each other so that's probably gonna require lookaheads of some kind. Hm....
PS: Most of the time when you write a for loop with an index iterating through the elements of an array, you'd be better off with a foreach loop. This is one of those cases:
for (@promoters_regex) { $total++ while $string =~ $_; }
-- Chip Salzenberg, Free-Floating Agent of Chaos
In reply to Re: Performance Tuning: Searching Long-Sequence Permutations
by chip
in thread Performance Tuning: Searching Long-Sequence Permutations
by Itatsumaki
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |