my $string = 'ALL CHANGE, THOSE GOING TO ASCOT'; my %hash; while ($string =~ /([AGCT])/g) { $hash{$1}++ } local $, = ' '; print %hash,"\n";