jumash has asked for the wisdom of the Perl Monks concerning the following question:

Hello everyone!

I have a huge perl-project, with cron-scripts, web-scripts and a portion of modules.

The task is to build a map for all the code - it means something like this at output:

- Script
-- using modules
-- sub containing
-- sub calling
-- (opt) variables using

The project is poorly PODed - so i cannot fully use NaturalDocs or DoxygenFilter.

I wrote part of needed code - but stopped at getting of subs calling by script - there's too many ways to call sub and i think that project implenents all of them :) Percentage of getting called subs is too small)

So i trying to find some ready2work product that generates code-struct-map with deps :)

Know something? Please, tell me :) Thanks!

Replies are listed 'Best First'.
Re: Code struct map building?
by Perlbotics (Archbishop) on May 13, 2010 at 09:01 UTC

    jumash,

    perhaps, you can delegate the parsing to B::Xref for each file and just parse & format the generated output as desired?

    From the docs:

    The B::Xref module is used to generate a cross reference listing of all definitions and uses of variables, subroutines and formats in a Perl program. It is implemented as a backend for the Perl compiler.

    Update:
    Concerning ready2work product - I didn't used it yet, but the following node should be worth a visit: Natural Doc - Create fancy documentation for your Perl code.

      I tried to use Xref - but lot of scripts contain DB-operations, modifying or evel deleting information.

      And, it is a bad idea to make triggers in hundred of scripts.

      That's the reason i'm searching for a some magic tool which will show me subs callings without compilation :(

      As for NaturalDocs - i also tried this - but as i said, the project is poorly PODed - and ND generates only a list of subs, which're DECLARED in scripts, NOT called. Sorry for my bad english :)

        Sorry for my bad text parsing capabilities this morning ;-)

        Well, I think such magic tool does not exist. Static structure can be Xref'ed but the run-time behavior depends on program-state, DB-information, time(?), etc. - something which might be documented by logging (e.g. for example sections of the docs and for analysis of program behavior). Beyond that, all tools rely on some commenting conventions to document the program semantics.

        What is the initial requirement anyhow? Do you want to compile a handbook (documentation) or do you want to chart a map of a given software package (orientation, job training)?

        In the long run, analyzing and (re-)documenting the code according to the conventions of the documentation tool you have chosen is the price to pay (aka tedious code maintenance work).

Re: Code struct map building?
by cdarke (Prior) on May 14, 2010 at 10:38 UTC