danielfortin86 has asked for the wisdom of the Perl Monks concerning the following question:
I was wondering if there was a faster way of recording the number of instances of a letter at a given position? Basically, the code below does what I'd like to do, but I'd like it to be faster since it will be run quite often. Any suggestions?
@seq = split(//,$string); $i = 0; foreach$letter(@seq){ switch($letter){ case "A" { $A[$i]++;} case "C" { $C[$i]++; } case "G" { $G[$i]++;} case "T" { $T[$i]++; } else{$N[$i]++;} } $i++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Iterating over string
by almut (Canon) on Apr 06, 2010 at 08:04 UTC | |
|
Re: Iterating over string
by BrowserUk (Patriarch) on Apr 06, 2010 at 08:06 UTC | |
|
Re: Iterating over string
by Corion (Patriarch) on Apr 06, 2010 at 08:09 UTC | |
|
Re: Iterating over string
by cdarke (Prior) on Apr 06, 2010 at 07:56 UTC | |
|
Re: Iterating over string
by biohisham (Priest) on Apr 06, 2010 at 08:15 UTC | |
|
Re: Iterating over string
by Jenda (Abbot) on Apr 14, 2010 at 12:38 UTC |