#!/usr/local/bin/perl -- -*- Perl -*- sub fname { $_[0] =~ m#/([^/]+)$#; $1; } sub src { $l{'src'}; } sub com { $l{'com'}; } sub tot { $l{'src'} + $l{'com'}; } sub perc { int(100 * $l{'com'} / &tot); } format top = File name Source Comments Blank Total % Comments ------------------------------------------------------------------------------- . format = @<<<<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<< @<<<<<<<<< @<<<<<<< @<<<<<< @>>> % &fname($ARGV), $l{SRC}, $l{COM}, $l{BLK}, $l{SRC} + $l{COM},int(100 * $l{COM} / ($l{SRC} + $l{COM})) . while (<>) { do { write; undef %l } if eof; do { $l{BLK}++; next; } if /^\s*$/; do { $l{COM}++; next; } if m#^\s*//.*$#; $l{SRC}++; } continue { $l{LNS}++; }