Do you want to statically analyse a perl program without running it, and get a call graph for all possible flows of the program, or do you want to run the program normally under some sort of debug environment so that you get back a call graph for your test run?

As moritz said, if you run a perl program under a profiler, then then you should be able to get a call graph from your profiling tool. The problem is that you only learn about the run you have just done, and not about any exceptional circumstances that you can't simulate. Also if your legacy code has bit rotted to the point where it won't run at all, and you can't easily fix it into a runnable state, then profiling it won't help you.

Instead it is tempting to want to generate a call graph from static analysis of a perl program without running it. Unfortunately that is a lot harder, not least because (as you will frequency hear) Only perl can parse perl. The meaning of the saying is that only the perl binary (perl.exe) can reliably parse perl, and the only way it can do so is to run the perl program. You can attempt to write a separate parser for perl, but perl.exe is the only definitive perl parser, and the only one guaranteed to be correct. Additionally, if the perl program you are trying to analyse is broken or otherwise buggy, then it's meaning is undefined, so by definition there is no correct outcome to parsing it.


In reply to Re: code analysis graph by chrestomanci
in thread code analysis graph by mostart

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.