#!/usr/bin/perl
use strict;
use warnings;
my $DNA = "GATTACACAT";
#initialize $countG and $currentPos
my $countG = 0;
my $currentPos = 0;
#calculate the length of $DNA
my $DNAlength = length($DNA);
#for each letter in the sequence check if it is the base G
#if 'yes' increment $countG
while($currentPos < $DNAlength){
my $base = substr($DNA,$currentPos,1);
if($base eq "G"){
$countG++;
}
$currentPos++;
} #end of while loop
#print out the number of Gs
print "There are $countG G bases\n";