foreach my $tri (@trilet) { my ($f, $s, $t) = $tri =~ /(.)(.)(.)/; $first{"$f$s"}++; $second{"$s$t"}++; $third{"$f$t"}++; }