Skip Menu |

This queue is for tickets about the Perl-Metric-Basic CPAN distribution.

Report information
The Basics
Id: 14962
Status: new
Priority: 0/
Queue: Perl-Metric-Basic

People
Owner: Nobody in particular
Requestors: chris+rt [...] chrisdolan.net
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 0.30
Fixed in: (no value)



Subject: Perl-Metrics command-line program
This module should include a simple command-line program to conveniently report metrics on .pm files. Here's a preliminary version that lacks proper @ARGV parsing, error checking and POD. If this is interesting to you, I would be happy to finish this and resubmit. #!/usr/bin/perl -w use strict; use PPI; use Perl::Metric::Basic; use Data::Dumper; for my $filename (@ARGV) { my $document = PPI::Document->new($filename); my $metric = Perl::Metric::Basic->new->measure($document); my %totals; for my $pkg (values %$metric) { for my $fn (values %$pkg) { for my $metricname (keys %$fn) { $totals{$metricname} ||= 0; $totals{$metricname} += $fn->{$metricname}; } } } print "$filename\n" if (@ARGV > 1); for my $metricname (sort keys %totals) { printf " %-16s %4d\n", $metricname, $totals{$metricname}; } }