#!/usr/bin/perl
use strict;
use warnings;

# initializing variables
my $dna_seq = "ATGCATTGGGGAACCCTGTGCGGATTCTTGTGGCTTTGGCCCTATCTTTTCTATGTCCAAGCTG".
              "TGCCCATCCAAAAAGTCCAAGATGACACCAAAACCCTCATCAAGACAATTGTCACCAGGATCAA";
my %NUCLEOTIDES = ();

# Looping throught the sequence
my $seqlen = length($dna_seq);
for (my $i = 0; $i < $seqlen; $i++) {
    my $char;
    $char = substr($dna_seq,$i,1);
    $NUCLEOTIDES{$char}++;
};

# Printing results
foreach my $nucleotide (sort keys %NUCLEOTIDES) {
    print STDOUT "Total $nucleotide = $NUCLEOTIDES{$nucleotide}\n";
};
