#!/usr/bin/perl -w
use strict;
my $subject = "AACGTACTGACGTACTGGTTGGTACGA";
my %results = ();
while ($subject =~ m/[ACTG][ATGC]/g) {
# matched text = $&
if(exists $results{$&})
{
$results{$&}++
}
else
{
$results{$&} = 1;
}
}
foreach (sort keys %results) {
print "$_ : $results{$_}\n";
}