Skip to content

Instantly share code, notes, and snippets.

@kaworu
Created December 12, 2013 09:43
Show Gist options
  • Save kaworu/7925498 to your computer and use it in GitHub Desktop.
Save kaworu/7925498 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# Simple code statistics script.
use feature qw(say);
while (<>) {
$total += 1;
$comment += 1 if m{^\s*(?:/\*|//|\*)};
$empty += 1 if /^\s*$/;
}
$code = $total - $empty - $comment;
# avoid a nasty division by 0.
$code = 1 if ($code eq 0);
format =
total: @###
$total
code: @###
$code
empty: @###
$empty
comment: @###
$comment
------------------------
comment/code ratio: @.##
$comment / $code
.
write();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment