#!/usr/local/bin/perl
#
# countman -- count the number of entries in a man tree

$|  = 1;
for (split(/:/, shift || $ENV{'MANPATH'} || '/usr/man')) {
    dbmopen(%whatis, "$_/whatis", undef) || (warn "$0: dbmopen $_: $!\n",next);
    print $_, ': ';
    for ($count = 0; each %whatis; $count++) { } 
    print $count, "\n";
} 
