Skip to content

Instantly share code, notes, and snippets.

@qlkzy
Created November 5, 2014 20:32
Show Gist options
  • Select an option

  • Save qlkzy/ca9d16e1ecb2a4c8428b to your computer and use it in GitHub Desktop.

Select an option

Save qlkzy/ca9d16e1ecb2a4c8428b to your computer and use it in GitHub Desktop.
Crude LaTeX wordcounter with ignoring
#!/usr/bin/env perl
my $wc = 0;
my @ignore = ('Abstract');
my $ig_pat = join '|', @ignore;
while (<>) {
/\\section\*?{(?:$ig_pat)}/ .. /\\section\*?{(?!:$ig_pat)}/ && next;
/\\begin{lstlisting}/ .. /\\end{lstlisting}/ && next;
$wc += scalar split /\s+/;
}
print "Words: $wc\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment