my $matches; for my $i (0..length($first) { if (substr($first,$i,0) eq substr($second,$i,0)) { $matches++; } }