10 my $binPath = $FindBin::Bin;
12 foreach $f ( @ARGV ) {
14 if ( $f =~ /\.lhs$/ ) {
15 open(INF, "$binPath/../../inplace/lib/unlit $f - |") || die "Couldn't unlit $f!\n";
17 open(INF, "< $f") || die "Couldn't open $f!\n";
28 $f_wc = `wc $f`; die "wc failed: $f\n" if $? != 0;
29 if ( $f_wc =~ /\s*(\d+)\s*(\d+)\s*(\d+)/ ) {
30 $comments = $1 - $cnt;
32 die "Can't grok wc format: $f_wc";
35 if ( $f =~ /(.*)\/(.*)/ ) {
38 $DirCount{$dir} += $cnt;
39 $ModCount{$mod} += $cnt;
40 $DirComments{$dir} += $comments;
41 $ModComments{$mod} += $comments;
43 print STDERR "not counted in a directory: $f\n";
44 $ModCount{$f} += $cnt;
45 $ModComments{$f} += $comments;
52 foreach $d (sort (keys %DirCount)) {
53 printf "%-20s %6d %6d\n", $d, $DirCount{$d}, $DirComments{$d};
54 $tot += $DirCount{$d};
55 $totcmts += $DirComments{$d};
57 printf "\n%-20s %6d %6d\n\n\n", 'TOTAL:', $tot, $totcmts;
61 printf "\n Code Comments\n";
62 foreach $m (sort (keys %ModCount)) {
63 printf "%-20s %6d %6d\n", $m, $ModCount{$m}, $ModComments{$m};
64 $tot += $ModCount{$m};
65 $totcmts += $ModComments{$m};
67 printf "\n%-20s %6d %6d\n", 'TOTAL:', $tot, $totcmts;