I'm not sure which way to go or even how to write what I need. Should I use 'opendir' or 'glob', I want to open a certain file when another file doesn't exist. I want to search a main directory and certain 2nd level sub directories, not all the 2nd level sub directories though, and not any 3rd level sub directories. Basically if "file_extn A = true" then continue search, if "file_extn A = false" then echo "file_extn B". I've uploaded a sample image to try and give a better idea. The blue cells indicate the directories I want to search, the yellow cells are directories I want to exclude from the search and the green cell is the file I want to echo, if anybody can help it would be greatly appreciated.

Diectory tree.jpg