brian d foy > SourceCode-LineCounter-Perl-1.02 > SourceCode::LineCounter::Perl

Download:
SourceCode-LineCounter-Perl-1.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.02   Source  

NAME ^

SourceCode::LineCounter::Perl - Count lines in Perl source code

SYNOPSIS ^

        use SourceCode::LineCounter::Perl;

        my $counter    = SourceCode::LineCounter::Perl->new;

        $counter->count( $file );
        
        my $total_lines   = $counter->total;
        
        my $pod_lines     = $counter->documentation;
        
        my $code_lines    = $counter->code;
        
        my $comment_lines = $counter->comment;

        my $comment_lines = $counter->blank;

DESCRIPTION ^

This module counts the lines in Perl source code and tries to classify them as code lines, documentation lines, and blank lines.

Read a line

If it's a blank line, record it and move on to the next line

If it is the start of pod, mark that we are in pod, and count it as a pod line and move on

If we are in pod and the line is blank, record it as a blank line and a pod line, and move on.

If we are ending pod (with =cut, record it as a pod line and move on.

If we are in pod and it is not blank, record it as a pod line and move on.

If we are not in pod, guess if the line has a comment. If the line has a comment, record it.

Removing comments, see if there is anything left. If there is, record it as a code line.

Move on to the next line.

new
reset

Reset everything the object counted so you can use the same object with another file.

accumulate( [ BOOLEAN ] )

With no argument, returns the current setting as true or false.

With one argument, sets the value for accumulation. If that's true, the counter will add to the count from previous calls to counter. If false, counter starts fresh each time.

count( FILE )

Counts the lines in FILE. The optional second argument, if true, adds those counts to the counts from the last run. By default, previous results are cleared.

total

Returns the total number of lines in the file

documentation

Returns the total number of Pod lines in the file, including and blank lines in Pod.

add_to_documentation

Add to the documentation line counter if the line is documentation.

code

Returns the number of non-blank lines, whether documentation or code.

add_to_code( LINE )

Add to the code line counter if the line is a code line.

comment

The number of lines with comments. These are the things that start with #. That might be lines that are all comments or code lines that have comments.

add_to_comment

Add to the comment line counter if the line has a comment. A line might be counted as both code and comments.

blank

The number of blank lines. By default, these are lines that match the regex qr/^\s*$/. You can change this in new() by specifying the line_ending parameter.

add_to_blank

Add to the blank line counter if the line is blank.

TO DO ^

SEE ALSO ^

SOURCE AVAILABILITY ^

This source is in Github

        https://github.com/briandfoy/sourcecode-linecounter-perl

AUTHOR ^

brian d foy, <bdfoy@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (c) 2008-2013, brian d foy, All Rights Reserved.

You may redistribute this under the same terms as Perl itself.

syntax highlighting: