in reply to Why am I getting wrong result in counting the number and kind of 2-letter in 3-letter words in a string?
If you have to take the first and third character of a string, you cannot do that with a single sub string, as you are not interested in the second character. Perhaps you want to do something along the lines of:
foreach my $tri (@trilet) { my ($f, $s, $t) = $tri =~ /(.)(.)(.)/; $first{"$f$s"}++; $second{"$s$t"}++; $third{"$f$t"}++; }
|
|---|