Skip to content
cobber edited this page Sep 13, 2010 · 10 revisions

Have you ever wondered which routines use a routine in your code?
Yes you can use grep etc, but wouldn’t it be nice to print out a graphical representation that people can understand?

perl_call_graph does just that. It analyzes any number(1) of perl source files and generates a graph of subroutine interactions.
I wrote this while trying to understand someone else code, which proved to be a great help.
Since then, I have discovered several “interesting” features in my own code. (for example, indirect cyclic dependencies etc.)

But be warned! Any sizable program is very probably going to generate very complex graphs, which is why perl_call_graph also allows you to specify which files and/or routines you are interested in – which greatly simplifies most graphs.

The visual representation of the graphs is not provided by this script directly. perl_call_graph generates a file which can be given to GraphViz (http://www.graphviz.org). This works wonderfully with the Mac OS X version, which automatically detects changes to the file and updates its display accordingly. On other platforms you might have to manually update the graphical representation after re-running perl_call_graph.

I hope this helps to make exploring your perl code more enjoyable!

If you have any questions or suggestions, please feel free to get in touch.

Steve

1: for reasonable values of “any”, depending on your hardware :-)

Clone this wiki locally