my %count; $count{$_}++ for map uc, split '', $protein; for ( 'A' .. 'Z' ) { say RESULT "$_: ", $count{$_} / length $protein if $count{$_}; }