in reply to My kingdom for a substring
Here is a thread on putting a directory structure into a hashed data structure, like Masem is saying.
How to map a directory tree to a perl hash tree