in reply to Strange problem with stat

Other comments are right and will work too. I like using glob for this sort of thing:
foreach (glob('*')) { ... }