#!/usr/bin/perl

$date=`date '+%b %e %H:%M'`;

open(T,"thesis.tex");
$/=undef;
$_=<T>;
$/="\n";
close(T);

$files='thesis.tex';
while (/\\input\{(.*?)\}/g) {
   $files.=" $1";
}

$_=`grep -a '/Type /Page\$' thesis.pdf | wc`;
/(\d+)/;
$pages=$1;

$_=`cat $files | wc`;
($_,$lines,$words,$chars)=split(/\s+/,$_);

$_=`grep \\\\\\\\TODO $files | wc`;
/(\d+)/;
$todos=$1;

$_=`grep \\\\\\\\FIXME $files | wc`;
/(\d+)/;
$fixmes=$1;

$_=`grep \\\\\\\\begin{proof} $files | wc`;
/(\d+)/;
$proofs=$1;

$_=`grep item thesis.ind | wc`;
/(\d+)/;
$index=$1;

$_=`grep undefined thesis.log | wc`;
/(\d+)/;
$undefined=$1-1;
$undefined=0 if $undefined<0;

$_=`grep 'multiply defined' thesis.log | wc`;
/(\d+)/;
$multiple=$1;

$_=`grep \\\\\\\\bibitem thesis.bbl | wc`;
/(\d+)/;
$bibit=$1;

$_=`grep ^@ thesis.bib conferences.bib | wc`;
/(\d+)/;
$bibdb=$1;

$_=`grep '^Overfull' thesis.log | wc`;
/(\d+)/;
$overfull=$1;

print "Thesis progress
$date
Pages: $pages
Lines: $lines
Words: $words
Chars: $chars
Index: $index
Biblio: $bibit/$bibdb
Proofs: $proofs

TODOs: $todos
FIXMEs: $fixmes
Undefs: $undefined
Multis: $multiple
Ofulls: $overfull
";
