I'm probably going to take over some pretty crufty Perl code shortly. So, the first thing I wanted to do is visualize exactly how crufty this program was. Fortunately for me, the code itself is pretty straightforward, except for the fact that it's spread out over 100 modules. That's before counting the roughly forty modules that are coming in from the core library (mostly things like strict, warnings, vars, Exporter, etc.), and another five or so that are from CPAN.
Looking around, I found Randy Ray's Devel::Modlist that will display the modules that get loaded when running a program. That's OK, but it's basically scouring %INC to find out what's been touched. What I want to do is find out what's being loaded and from where -- what are the relationships in this suite.
So, after looking through Devel::Modlist and perldebguts, I hacked together a little debugger that does some of what Devel::Modlist does, but then continues by rooting around each of the loaded files for use statements. How are they visualized? Why, graphviz of course!
It's not perfect, but it gets the job mostly done. What I'd really like to see is a way to intercept use statements in the debugger for each use statement found. But that's not the way Perl works. (I rooted around with the undocumented DB::postpone interface...)
Perhaps what I really need is a source filter that strips out nonexecutable portions of a program -- comments, POD, __DATA__ sections, etc. and inspect them after Acme::Bleach is done it's dirty work. Then a regex for use statements might be a little more reliable...