wc... see?
git-svn-id: file:///home/svn/incoming/trunk@2589 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
e1c4b45e2f
commit
9749724a80
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
my $total = 0;
|
||||||
|
my $blank = 0;
|
||||||
|
my $comment = 0;
|
||||||
|
|
||||||
|
while(<STDIN>) {
|
||||||
|
my $line = $_;
|
||||||
|
chomp($line);
|
||||||
|
|
||||||
|
$total++;
|
||||||
|
|
||||||
|
if($line =~ /^\s*$/) {
|
||||||
|
$blank++;
|
||||||
|
}
|
||||||
|
elsif($line =~ /^\s*#/) {
|
||||||
|
$comment++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
my $other = $total - $blank - $comment;
|
||||||
|
|
||||||
|
printf("Total: %4d\n", $total);
|
||||||
|
|
||||||
|
if($ARGV[0] eq '-noblank') {
|
||||||
|
$total -= $blank;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("Blank: %4d ( %.2f%% )\n", $blank, $blank / $total * 100);
|
||||||
|
printf("Comments: %4d ( %.2f%% )\n", $comment, $comment / $total * 100);
|
||||||
|
printf("Other: %4d ( %.2f%% )\n", $other, $other / $total * 100);
|
||||||
|
|
Loading…
Reference in New Issue