The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long ();
use Perl::Metrics::Lite;
use Pod::Usage;
use Perl::Metrics::Lite::Report::Text;

our $VERSION = "0.05";

my $show_only_error = 0;
Getopt::Long::GetOptions(
    'h|help'                        => \my $help,
    'verbose'                       => \my $verbose,
    'l|max_sub_lines=i'             => \my $max_sub_lines,
    'c|max_sub_mccabe_complexity=i' => \my $max_sub_mccabe_complexity,
    'e|show_only_error'             => \$show_only_error,
) or pod2usage();

pod2usage() if $help;

main();
exit;

sub main {
    report( \@ARGV );
}

sub report {
    my $files    = shift;
    my $reporter = Perl::Metrics::Lite::Report::Text->new(
        max_sub_lines             => $max_sub_lines             || 60,
        max_sub_mccabe_complexity => $max_sub_mccabe_complexity || 10,
        show_only_error           => $show_only_error
    );
    my $analzyer = Perl::Metrics::Lite->new( report_module => $reporter );
    my $analysis = $analzyer->analyze_files(@$files);
    $analzyer->report($analysis);
}

__END__

=head1 NAME

measureperl - count lines, packages, subs and complexity of Perl files.

=head1 SYNOPSIS

Show all metrics
  B<measureperl> F<FILE_OR_DIRECTORY> [F<FILE_OR_DIRECTORY> ....]
  ex) measureperl lib

Show only errors in subroutines
  measureperl -e lib

Show only method which sloc is 50 and mccabe's complexity is over 10
  measureperl -e -l 50 -c 10 lib 

=head1 REQUIRED ARGUMENTS

At least one file or directory path must be supplied.

=cut