in reply to make-like dependency tools in perl

You may be able to get some ideas from Module::Dependency. There are three parts; I think the important bits for you would be in the Indexer. I haven't delved into the code, but I've used it and it does a good job.