Dave's Free Press

Tech: find dependencies in perl code

 

Older stuff

source code (v1) | source code (v2)

One of the hardest things about managing a large project is keeping track of all the dependencies between files - things like what file contains what function, what functions call what other functions, and so on. Whilst deep in just such a nasty project, I wrote this tool to help me.

It does not guarantee to be 100% accurate, but it certainly does a pretty good job. One area where it will get horribly confused is if you use those nasty EXPORT and EXPORT_OK things. The ensuing cross-pollination between namespaces will not be accurately reported. Method calls are also not well handled.

The most recent version will skip over POD markup, and uses a more accurate method of detecting which package a subroutine is in.

Yes, the code is crufty. I originally wrote it in 1999, and I'd do it completely differently these days. Patches welcome.

Walery Studennikov of Webnames.ru submitted patches to allow customising what the script reports on, to split status and results messages into STDERR and STDOUT, some limited support for OOish code, and to use B::Deparse. His code is in version 2, which I recommend you use. Most of his patches will only take effect if you explicitly turn them on.