Here is my solution:
use strict; use warnings; my $string = "CTCCGGATCTAT"; my $sets = length($string)/3; # we want to know how man +y sets of 3 there are my $unpacker = 'A3' x $sets; # create our unpack templ +ate my @dna = unpack($unpacker, $string); # create the array of set +s my $counter = 0; # initialize the counter for my $set (@dna) { # for each $set in @dna d +o... my $check = substr($set, 2, 1); # get the 3rd char of the + $set ++$counter if ($check =~ /[GC]/i); # increment the counter, +ignore case } print "$counter/$sets was either C or G.\n"; # print results
In reply to Re: for loops
by Mr. Muskrat
in thread Count every 3rd base occurence
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |