What you've done in your code is create an array with each element only one character in length, so when you use ~~ smartmatch against the array, you're only testing against a substring of a single character.
If I understand what you're attempting to do, this code may help get you on your way:
#!/usr/bin/perl
use warnings;
use strict;
my $str = 'abcdefghijkl';
my %match = (ab => 0, abcd => 0, xyz => 0,);
for my $key (keys %match){
if ($str =~ /$key/){
$match{$key}++;
}
else {
print "$key not found in $str\n";
}
}
for my $k (keys %match){
print "key: $k value: $match{$k}\n";
}
-stevieb