in reply to stupid/simple mistake

You need the /g switch to your regex match:
for ($sequence =~ /$substring/g) {
and, of course, increment $count in the inner loop.