in reply to How to count substrings in an array?
Well, “goatse” is Cute Golf, but I would veto its use in a code review because it simply isn’t instantaneously obvious, not only that the code does work correctly, but that it does so in every case.
The ideal, of course, would be that the code is supported by Test::More test suites that thoroughly exercise all relevant cases to prove not only that it works properly in every case that might be thrown at it, but that it also rejects any invalid string that violates one of its design assumptions. (That’s a lot more work for the programmer, so I usually encounter “nasty bugs in production” instead. So do you. So it goes.)
What if the substring contains instances of itself, or tails with its own head?
For instance, how many occurrences of aba do you want to say occurs in the string abababa? Two, or three? You have two design choices here, and you must know what is the right answer for the purposes of this application in a production setting.