# S.Chudley (www.chudley.me) : Count number of lines in C++ app, where files end cc|c|hh|h my $l_extensions = "cc|c|hh|h|cpp|hpp"; my $l_count = 0; &count_dir("."); sub count_dir { my $a_path = shift; chomp(my @l_files = `dir /B $a_path`); foreach my $l_name (@l_files) { my $l_file = $a_path."\\".$l_name; if (-f $l_file and $l_file =~ m/\.($l_extensions)$/i) { my $l_c = 0; open(INF, $l_file); while (my $l_line = ) { if ($l_line !~ m/^\s*\/\// and $l_line !~ m/^\s*\*/ and $l_line !~ m/^\s*\/\*/ and $l_line !~ m/^\s*#/ and $l_line !~ m/^\s*$/) { $l_c++; } } close(INF); $l_file =~ s/^\.\\//; print $l_file.": ".$l_c."\n"; $l_count += $l_c; } elsif (-d $l_file) { &count_dir($l_file); } } } print "\nTotal: $l_count\n";