12 my $binPath = $FindBin::Bin;
14 foreach $f ( @ARGV ) {
16 if ( $f =~ /\.lhs$/ ) {
17 open(INF, "$binPath/../../inplace/lib/unlit $f - |") || die "Couldn't unlit $f!\n";
19 open(INF, "< $f") || die "Couldn't open $f!\n";
30 $f_wc = `wc $f`; die "wc failed: $f\n" if $? != 0;
31 if ( $f_wc =~ /\s*(\d+)\s*(\d+)\s*(\d+)/ ) {
32 $comments = $1 - $cnt;
34 die "Can't grok wc format: $f_wc";
37 if ( $f =~ /(.*)\/(.*)/ ) {
40 $DirCount{$dir} += $cnt;
41 $ModCount{$mod} += $cnt;
42 $DirComments{$dir} += $comments;
43 $ModComments{$mod} += $comments;
45 print STDERR "not counted in a directory: $f\n";
46 $ModCount{$f} += $cnt;
47 $ModComments{$f} += $comments;
54 foreach $d (sort (keys %DirCount)) {
55 printf "%-20s %6d %6d\n", $d, $DirCount{$d}, $DirComments{$d};
56 $tot += $DirCount{$d};
57 $totcmts += $DirComments{$d};
59 printf "\n%-20s %6d %6d\n\n\n", 'TOTAL:', $tot, $totcmts;
63 printf "\n Code Comments\n";
64 foreach $m (sort (keys %ModCount)) {
65 printf "%-20s %6d %6d\n", $m, $ModCount{$m}, $ModComments{$m};
66 $tot += $ModCount{$m};
67 $totcmts += $ModComments{$m};
69 printf "\n%-20s %6d %6d\n", 'TOTAL:', $tot, $totcmts;