How can I count the corresponding lines for each unit in my perl code?

I am reorganizing a rather large piece of code, and some esoteric question came to me, wondering where to continue this. The fact that this code needs more details is a reduction in subsystems.

Thus, it would be very useful to specify some kind of statistics collector in the directory that will go through all the .pm, .cgi and .pl files, find all the subsets (I'm fine if it only gets named) and gives me a table of all of them, as well as their number of rows.

I gave PPI a quick look, but could not find anything relevant, with some tools that may be suitable, but quite difficult to use.

Are there any simpler modules that do something like this?

Otherwise, how would you do it?

Edit:

I lost PPI a bit and created a script that collects relevant statistics from the code base: http://gist.github.com/514512

+4
source share
2 answers
my $document = PPI::Document->new($file); # Strip out comments and documentation $document->prune('PPI::Token::Pod'); $document->prune('PPI::Token::Comment'); # Find all the named subroutines my $sub_nodes = $document->find( sub { $_[1]->isa('PPI::Statement::Sub') and $_[1]->name } ); print map { sprintf "%s %s\n", $_->name, scalar split /\n/, $_->content } @$sub_nodes; 
+10
source

I doubt that simply defining long functions is the best way to determine what needs to be reorganized. Instead, I will run the code through perlcritic with increased rigidity and follow the recommendations.

+3
source

All Articles