The code I posted was to demonstrate a way to recursive call self, not being very useful in itself... ;-)
There is more than one way to do it. You could rewinddir and readdir again (with a different grep) on the same handle too..
But I agree that your solution is beautiful.
Maybe someone could benchmark some testcases.