View on GitHub

Perl::Analyzer

A tool to analyze and visualize large Perl codebases

Download this project as a .zip file Download this project as a tar.gz file

Perl-Analyzer is a set of programs (and modules which can be used separately) that allow you to analyze and visualize Perl codebases:

The software is split into two parts - analyzer (perl-analyzer, which uses Perl::Analyzer module) and renderer (perl-analyzer-output, which uses Perl::Analyzer::Output and related plugins).

Example

Let's do an analysis of DBIx::Class module:

perl-analyzer --source-dir=DBIx-Class-0.082840 --datafile=DBIx-Class.dat

perl-analyzer-output --datafile=DBIx-Class.dat --output-dir=./DBIx-Class-Analysis --format=html

perl-analyzer-output --datafile=DBIx-Class.dat --output-dir=./DBIx-Class-Analysis 
    --format=png --options="rankdir=LR"

Here are the results:

Browse HTML output of analysis of DBIx::Class

Example page with analysis of DBIx::Class::Schema::Versioned package

Namespaces chart Package inheritance chart
(Click on images to view them in full size)

Usage

perl-analyzer

perl-analyzer --source-dir source_dir --datafile file [--verbose]
   [--with-constants] [--with-fields]

--source-dir, --src

Directory with Perl source code to analyze.

--datafile, --data

Output file with analysis data. Should be used as input file for perl_analyzer_output.

--verbose

Print processing information to stdout.

--with-constants

Parse 'use constant'.

--with-fields

Parse 'use fields'.

perl-analyzer-output

perl-analyzer-output --datafile file --output-dir dir
   --format [dot|dump|html|json|png|svg]
   [--options "options_string"] [--filter "filter_regexp"] [--verbose]

--datafile, --data

Input file with analysis data.

--output-dir, --out

Output directory. Created automatically if does not exist.

--format format_name

Defines output format.

--options "opt1=val1;opt2=val2"

Define options for given format.

--filter "filter_regexp"

Include only modules with names matching the regexp.

--verbose

Print processing information to stdout.

Output formats

dump (requires Data::Dumper)

Generates set of dump files for Perl::Analyzer structures. Useful for debugging purposes.

json (requires JSON)

Generates set of JSON files.

html (requires Text::MicroTemplate and JSON)

Generates set of HTML files. Most informative and useful output - it allows to navigate through namespaces and view detailed package information.

dot, svg, png (requires GraphViz2)

Generates namespace and inheritance diagrams in given format. For large codebases please use SVG format, since PNG has size limitations.

Installation

To install this module, run the following commands:

perl Makefile.PL
make
make test
make install

Acknowledgements

File analyzer code based on Module::Dependency by Tim Bunce and P Kent.

License and copyright

Copyright (C) 2015 Serhii Mozhaiskyi

This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0).