Tuesday, October 03, 2006


Counts files, packages, subroutines, and calculates cyclomatic complexity of Perl files.

I recently released an alpha version of new Perl module: Perl::Metrics::Simple

There is an included script, in the examples/ directory which produces output like this:

Perl Files: $file_count

Line Counts
lines: $lines
packages: $package_count
subs: $sub_count
all main code: $main_stats->{lines}

min. sub size: $lines{min} lines
max. sub size: $lines{max} lines
avg. sub size: $lines{average} lines
median sub size: $lines{median}

McCabe Complexity
min. main: $main_complexity{min}
max. main: $main_complexity{max}
median main: $main_complexity{median}
average main: $main_complexity{average}

min: $complexity{min}
max: $complexity{max}
avg: $complexity{average}
median: $complexity{median}
std. deviation: $complexity{standard_deviation}


vargusvictor said...

Cool Blog! I am a student (C++ programming). I am familiar with networking and systems architecture, but this is my first semester of programming. I want to learn to use Perl (and others too) because I use Ubuntu, Gentoo, Knoppix, Debian and PC Linux (and perfer any of them over XP or Vista). Although I am learning using Microsoft's IDE (visual studio .NET 2003), and I have yet to really begin learning any programming skills using any other tools besides Microsoft ones, I am a believer in open sources and a non-believer in overbearing software patents and the like. It is still my desire to learn how to program by working within the open source community and helping wherever I am needed. I won't bug you with a bunch of questions about programming, but I do look forward to using your blog as one of the resources that help me grow as a programmer. Already I have learned a few things about C++ (that I didn't learn in class) just from looking at some of the source you have on this blog (and links to). I recognize a lot of it as being similar to C++. So I figure maybe learning both C++ and another similar language at the same time (maybe Perl) is the best thing to do. I have some IDEs that I can download from the Ubuntu/Debian repositories and your blog will help me get a view of programming other than that of my professor.


Matisse Enzer said...

Thanks vic.

I think you'll find that Perl is a very useful language to learn, it has a great deal of the power of C, along with objects, and no need for memory management. On the other hand, the development tools for Perl are years behind what is available for Java, although there is a decent Perl plug-in for the open source Eclipse IDE. (See http://eclipse.org/ and http://e-p-i-c.sf.net/) See also my article: http://twoalpha.blogspot.com/2005/08/perl-needs-better-tools.html