A report could look like this:
% analyze.pl path/to/directory/of/perl/code
files: 39
lines: 15929
packages: 39
subs: 336
The module is (very tentively) named Perl::Code::Analyze and uses
Adam Kennedy's PPI module for the real work.
A (very) alpha version of the module is at
http://g5-imac.matisse.net/~matisse/Perl-Code-Analyze-0.01
Here's an example of a script that would use Perl::Code::Analyze
to produce the report shown above:
#!/usr/bin/perl
use strict;
use warnings;
use Perl::Code::Analyze;
my $analzyer = Perl::Code::Analyze->new;
my $analysis = $analzyer->analyze_files(@ARGV);
my $file_count = $analysis->file_count;
my $package_count = $analysis->package_count;
my $sub_count = $analysis->sub_count;
my $lines = $analysis->lines;
print <<"EOS";
files: $file_count
lines: $lines
packages: $package_count
subs: $sub_count
EOS
exit;
No comments:
Post a Comment