in reply to Counting elements in array
You have (at least) a couple of options:
Your pick. You need to force scalar context, which I explicitly did by using the scalar function.