Is there a way to count the number of entries in an .idx file? Currently I'm using the following to accomplish the job but I'm wondering if there is an all TeX/LaTeX way to accomplish the same thing. Were there then I wouldn't have to fit a run of 'Count' into the build process. Here is the code:
#!/usr/bin/perl
# Count.pl -- generate index count info for tex
use strict;
use warnings;
use diagnostics;
our $VERSION = '0.04';
UpdateLines('names.tex',NLines($ARGV[0] . '.idx'));
UpdateLines('places.tex',NLines('places.idx'));
sub NLines {
my $filename = shift;
my @f;
my $fh;
open($fh, '<', $filename);
@f = <$fh>;
return scalar @f;
}
sub UpdateLines {
my $filename = shift;
my $lines = shift;
my $fh;
open($fh, '>', $filename);
print $fh "There are $lines entries in this index.\n";
}
It occurs to me as I write this that since I use a collection of macros to index the various forms of names and places that I could add the necessary to increment the obvious counters inline so to speak. If anyone else has a better idea, jump on board. If not and if I manage to cobble something together then I'll post it as an answer in case someone else has this counting compulsion. OCD much?



\indexto add to a CSV the list of enteres that are indexed (if not already in the list), and then\AtEndDocumentcount the number of elements in this CSV. – Peter Grill Mar 17 at 1:29wc -lis easier than the perl script (except that you've already written the perl script). – Ethan Bolker Mar 17 at 1:31xindyormakeindex? – Marco Daniel Mar 17 at 6:57There are n entries in this index.The Perl script was how I counted them simply by counting lines in the.idxfile created bymakeindex. – hsmyers Mar 17 at 9:17Editor's Disease! As do I :) The answer is that precision is not a requirement here. Since this is a family history, the numbers are more of a guide than anything else. At the moment, the naive approach just counts lines in the.idxfiles. My new approach counts each instance of indexing. I'll have to give this some thought as to what would be best. Luckily the audience is un-critical :) – hsmyers Mar 17 at 12:18